Git是Linux撞始人Linus Towards花一周写出来的分布式版本控制系统,大神终究是大神,这么牛逼的东西只需要一周。之前花了一百多刀买了Linus的原版自传《Just for fun》,基本上是他自己写的,很幽默,有兴趣可以看看。Linus很傲,但是傲得有资本,唯一能无视Jobs的现实扭曲力场,对Jobs的盛情邀请say no转身而去的人。 
最重要的命令: git  –help  
Git配置 1 2 3 4 5 6 7 8 9 10 git config --global user.name "huaqianlee"     git config --global user.email "huaqianlee@gmail.com"      git config --global color.ui true  git config --global alias.co checkout  git config --global alias.ci commit git config --global alias.st status git config --global alias.br branch git config --global core.editor "mate -w"      git config -l   
用户的git配置文件~/.gitconfig
 
Git常用及进阶命令 常用命令 1 2 3 4 5 git help    git init     git clean -fd   git clean -fX   git clean  
添加 1 2 3 git add file    git add .         git add -A      
删除 1 2 git rm  file          git rm  <file> --cached   
撤销回退 1 2 3 4 5 6 7 8 9 10 11 12 13 14 git checkout -- xx   git checkout .      git checkout ${commit}  /path/to/file  git revert <$id >     git revert HEAD      git reset <file>     git reset -- .       git reset  –hard HEAD^/HEAD~   git reset  –hard <commit_id>     git reset HEAD file   git revert <commit>   git add (--all)/git rm /...  git revert --continue   
提交 1 2 3 4 5 git commit  <file>  git commit –m “description”    git commit -a            git commit -am "some comments"  git commit --amend       
查看状态记录 1 2 3 4 5 6 7 8 9 10 git status         git show ($id )   git log    (file)        git log  -p <file>    git log  -p -2        git log  --stat        git reflog        git log  -g  git log  -- grep "name"   git log  record-ID  -l -p  
查看差异 1 2 3 4 5 6 7 8 git diff <file>      git diff    git diff master..Andylee-Github/master  git diff <$id1 > <$id2 >    git diff <branch1>..<branch2>  git diff --staged    git diff --cached    git diff --stat       
本地分支管理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 git branch   git branch  -r     git branch  -a      git branch   <new_branch>  git branch   -v            git branch   --merged      git branch   --no-merged   git checkout <branch>   git checkout –b <new_branch> git merge dev     git checkout -b <new_branch> <branch>   git checkout  $id            git checkout  $id  -b <new_branch>   git branch-d <branch>   git branch-D <branch>   git merge <branch>                git merge origin/master --no-ff   git rebase master <branch>        git cherry-pick <commit>   git checkout -b newbranch <last_commit>  git rebase --onto master <first_commit>^   
补丁应用 1 2 3 git diff > ../sync.patch          git apply ../sync.patch           git apply --check ../sync.patch   
暂存管理 1 2 3 4 5 git stash   git stash list   git stash apply   git stash drop   git stash pop   
远程分支管理 1 2 3 4 5 6 7 8 9 10 11 12 13 git pull                          git pull --no-ff                  git fetch origin                  git merge origin/master           git checkout   --track origin/branch      git checkout   -b <local_branch> origin/<remote_branch>   git push                          git push origin branch    git push –u origin branch    git push origin <local_branch>    git push origin <local_branch>:<remote_branch>   git push origin :<remote_branch>   
远程仓库管理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 git remote   git remote –v   git remote show origin            git remote add origin git@github:robbin/robbin_site.git          git remote set-url origin git@github.com:robbin/robbin_site.git  git remote rm  <repository>        git clone  https://github.com/AndyLee-Github/cartboon.git    git clone  --bare robbin_site robbin_site.git   scp -r my_project.git git@git.csdn.net:~       mkdir  robbin_site.git + cd  robbin_site.git + git --bare init git remote add origin git@github.com:robbin/robbin_site.git     git push -u origin master                                       git push -u origin develop   git remote set-head origin master    
命令设置跟踪远程库和本地库 1 2 git branch --set-upstream master origin/master git branch --set-upstream develop origin/develop 
create a new repository on the command line 1 2 3 4 5 6 echo  "# hexo-theme"  >> README.mdgit init git add README.md git commit -m "first commit"  git remote add origin git@github.com:huaqianlee/hexo-theme.git git push -u origin master 
push an existing repository from the command line 1 2 git remote add origin git@github.com:huaqianlee/hexo-theme.git git push -u origin master 
目前先这么多,后续再补充更高级的命令, 也可参考:git进阶 ,git资料整理 。