master : 默认开发分支; origin : 默认远程版本库
初始化操作
1 2 3 4 5
| $ git config -global user.name <name> $ git config -global user.email <email> $ git config -global core.editor <editor> $ git config -global merge.tool <tool> $ git config -list
|
创建新版本库
1 2
| $ git clone <url> $ git init
|
修改和提交
1 2 3 4 5 6 7 8 9
| $ git add . $ git add <file> $ git mv <old> <new> $ git rm <file> $ git rm -cached <file> $ git commit -m <file> $ git commit -m “commit message” $ git commit -amend $ git commit -C HEAD -a -amend
|
查看提交历史
1 2 3 4 5 6 7 8 9
| $ git log $ git log -p <file> $ git blame <file> $ gitk $ gitk <branch> $ gitk --all $ git branch -v $ git status $ git diff
|
撤消操作
1 2 3 4 5
| $ git reset -hard HEAD $ git checkout HEAD <file1> <file2> 修改内容 $ git checkout HEAD. $ git revert <commit>
|
分支与标签
1 2 3 4 5 6 7
| $ git branch $ git checkout <branch/tagname> $ git branch <new-branch> $ git branch -d <branch> $ git tag $ git tag <tagname> $ git tag -d <tagname>
|
合并与衍合
1 2
| $ git merge <branch> $ git rebase <branch>
|
远程操作
1 2 3 4 5 6 7 8
| $ git remote -v $ git remote show <remote> $ git remote add <remote> <url> $ git fetch <remote> $ git pull <remote> <branch> $ git push <remote> <branch> $ git push <remote> : <branch>/<tagname> $ git push -tags
|