Git Usage Tips
$ git merge --no-ff --no-commit dev
rebase - 修改 Commit History
A-->B-->C-->D-->E master
删除某些commit可以用如下的rebase
命令
A-->B-->C-->D-->E master
$ git rebase -onto A C master
A-->D-->E master
也可以使用interactive模式:
A-->B-->C-->D-->E master
$ git rebase -i -onto A A master
interactive模式下会跳出commit list供用户进行编辑
pick
- 默认行为edit
- 编辑,然后继续git rebase --continue
reword
- 只是重新编辑commit message
fixup
- 与前面的commit合并,保留第一各commit的属性squash
- 合并commit时保留该commit的message
- 改变列表顺序来改变commit的顺序
- 删除行来跳过相应的commit
cherry-pick - 挑挑拣拣地合并
$ git cherry-pick -n dev~2 dev
error: could not apply f938530... fix travis config
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: src/generic/interpool.c
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
both modified: .travis.yml
$ git diff
diff --cc .travis.yml
index 36ef76b,e2da5df..0000000
mode 100644,100644..100755
--- a/.travis.yml
+++ b/.travis.yml
...
$ git add .travis.yml
$ git diff --cached
gh-pages - GitHub Project Page
$ git checkout --orphan gh-pages
$ git add ; git commit ; ...
$ git push -u origin gh-pages
Merge Upstream - 合并fork上游的修改
$ git remote -v
origin [email protected]:noyesno/tclx.git (fetch)
origin [email protected]:noyesno/tclx.git (push)
$ git remote add upstream [email protected]:flightaware/tclx.git
origin [email protected]:noyesno/tclx.git (fetch)
origin [email protected]:noyesno/tclx.git (push)
upstream [email protected]:flightaware/tclx.git (fetch)
upstream [email protected]:flightaware/tclx.git (push)
$ git fetch upstream
$ git merge upstream/master