Git
1 Basic
config
- git config –list
status
- git status -s
alias
- git config –global alias.ci commit -> git ci
- git config –global alias.unstage 'reset HEAD –'
- git config –global alias.last 'log -1 HEAD'
.gitignore
- glob 模式匹配
/开头防止递归/结尾指定目录!忽略之后再取反特定文件**匹配任意中间目录
diff
- git diff –staged/cached
rm
- git rm –cached: staged -> untracked
checkout
- git checkout – <file>: unstaged -> untracked
- git checkout -b <branch-name> <tag-name>
reset
- git reset HEAD <file> -> unstaged
log
-p, -2, –stat, –shortstat, –graph, –abbrev-commit, –since, –until, –author, –grep, -S
commit
- git commit –amend
remote
- git remote -v
- git remote add <name> <url>
- git remote rm <remote-name>
- git remote show <remote-name>
- git remote rename <old> <new>
fetch
- git fetch <remote-name>
push
- git push origin master
- git push origin <tag-name>
- git push origin –tags
tag
- git tag -l 'v1.0.*'
- git tag -a <tag-name> -m 'comments' <commit-hash>
- git show <tag-name>
2 Branch
创建
- git branch <branch-name>
- git checkout -b <branch-name>
branch
-v, --merge, --no-merge
HEAD 指针
HEAD 指针指向当前所在的本地分支
查看分支历史
- git log –oneline –decorate –graph –all
merge
- git merge <branch-name>