http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
$ tar xzf project.tar.gz
$ cd project
$ git init
$ git add .
————————————–
$ git add file1 file2 file3 #updated contents to the index:
$ git diff #git diff will show you any changes that you’ve made but not yet added to the index
$ git diff –cached #–cached will show you any changes you’ve added to the index
$ git commit -a
$ git log
$ git log -p
$ git log –stat –summary
$ git log –all #显示所有log,包括reset之前的commit ID
$ git log –pretty=oneline master
$ git reset #取消当前git add到index中(commit之前先加入index)所做的修改
$ git reset PREVIOUS_COMMIT #取消某个已check in的commit(默认是–mixed的,参见–hard,–soft)
—————————————
$ git branch experimental
$ git branch
experimental
* master
$ git checkout experimental
$ git merge experimental
$ git branch -d experimental #experimental branch里的改变已经被merge过
$ git branch -D crazy-idea #强行删除,不管有没有merge
—————————————-
alice/bob collaboration (alice owned the git repository)
bob$ git clone /home/alice/project myrepo
alice$ cd /home/alice/project
alice$ git pull /home/bob/myrepo master #This merges the changes from Bob’s "master" branch into Alice’s current branch
alice$ git fetch /home/bob/myrepo master #will not merge
alice$ git log -p HEAD..FETCH_HEAD
###
This operation is safe even if Alice has uncommitted local changes. The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable from the FETCH_HEAD but exclude anything that is reachable from HEAD". Alice already knows everything that leads to her current state (HEAD), and reviews what Bob has in his state (FETCH_HEAD) that she has not seen with this command.
###
$ gitk HEAD…FETCH_HEAD
alice$ git remote add bob /home/bob/myrepo
alice$ git fetch bob
alice$ git log -p master..bob/master
alice$ git merge bob/master
alice$ git pull . remotes/bob/master #This merge can also be done by pulling from her own remote tracking branch
bob$ git pull #doesn’t need to give the path to Alice’s repository
bob$ git branch -r
——————————————
$ git show HEAD^ # to see the parent of HEAD
$ git show HEAD^^ # to see the grandparent of HEAD
$ git show HEAD~4 # to see the great-great grandparent of HEAD
$ git tag v2.5 1b2e1d63ff #give commits names of your own;
$ git branch stable v2.5 # start a new branch named "stable" based at v2.5
——————————————
$ git config –list #查看所有的git config项
###使用alias将某些常用命令缩写为更简便的短语
$ git config –global alias.co checkout
$ git config –global alias.ci commit
$ git config –global alias.st status