Git rebase 笔记 ( git rebase introduction)

访问量: 1723

前几天的一个文章,我提到 自己比较偏好 git-merge. 现在看起来,这个问题不该带有个人偏好。而是需要根据情况,来选择使用 git rebase /merge  ( several days ago, I mentioned that I prefer 'git-merge' to 'git-rebase'.  Now I admit that as a professional programmer, I should not be emotional.  We should choosing the right one according to the real situation ) 

merge: 会保留时间线。 适合需要保持时间线的场合。  (it would keep the commit order for each branch ) 

rebase: 不会保留时间线。 适合按照 feature 来查看log的场合。比如,我现在同时在3个分支上工作,但是为了方便代码的提交,我会在一个完成之后再提交另外一个分支/功能模块。所以在这样的情况下使用rebase使得代码更加容易回滚,以及查看log.   ( the origin commit would be removed and a new commit would be generated .  if you are working on 3 branches at the same time, and want to merge the code till the whole module/branch is done, just use this 'rebase' ) 

简单用法:

$ git rebase master <current_branch>

这样就会把 master上的最后一个commit, 做为当前 分支的commit 的基础。

更多详细,参考 man git-rebase.   ( for more details, please refer to 'man git-rebase' ) 

订阅/RSS Feed

Subscribe

分类/category