git.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 29 Mar 2009 17:23:41 +0300
changeset 61 997e7523b171
child 62 4cda4557f554
permissions -rw-r--r--
About git.

-*- outline -*-

* Setup git.

** Debian.

For Etch Degian release use git-core package from backports,
old 1.4 version of git very dumb compared to new version 1.5.

  $ sudo apt-get install git-core

After install setup some options:

  $ git config --global user.name "Oleksandr Gavenko"
  $ git config --global user.mail "gavenkoa@gmail.com"
  $ cat ~/.gitconfig
[user]
    name = Oleksandr Gavenko
    mail = gavenkoa@gmail.com

* Start your project.

Setup proj space on fs.

  $ mkdir proj
  $ cd proj
  $ git init
Initialized empty Git repository in /home/user/tmp/proj/.git/
  $ ls -a
. .. .git

Add file, make changes, commit all.

  $ emacs Makefile
... C-x C-c
  $ emacs app.c
... C-x C-c
  $ git add Makefile app.c
  $ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file: Makefile
#       new file: app.c
#

or just

  $ git add .

Commit newlly added file:

  $ git commit
... Write message log ...
Created initial commit 2169263: My first commit massage.
 1 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 app.c

* Undo tracking added file.

You do

  $ git add badfile
  $ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   badfile
#

To stop tracking badfile do

  $ git rm --cached badfile
  $ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       file
nothing added to commit but untracked files present (use "git add" to track)

or

  $ git reset badfile

* Doing changes.

  $ printf "clean:\n<TAB>rm $(wildcard *.o)" >>Makefile
  $ git diff
diff --git a/Makefile b/Makefile
index e84f7e9..cd2438a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,5 @@
 all:
        @echo XXX
        exit 1
+
+clean:
+       rm -f *.o
\ No newline at end of file
  $ git add Makefile
  $ git commit -m "Added clean target."
Created commit 11272b9: Added clean target.
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file

or just

  $ git commit -a -m "Added clean target."

* Using git to work with SVN offline.

  $ sudo apt-get svn git-core git-svn
  $