- 更新 fork 的仓库
git remote add upstream https://github.com/whoever/whatever.git
git fetch upstream
git checkout master # Make sure that you're on your master branch:
git rebase upstream/master
- merge分支到master
(dev-branch)$ git merge master //(resolve any merge conflicts if there are any)
git checkout master
git merge dev-branch //(there won't be any conflicts now)
https://stackoverflow.com/questions/14168677/merge-development-branch-with-master
merge
- 自动创建一个新的commit
- 如果合并的时候遇到冲突,仅需要修改后重新commit
- 优点:记录了真实的commit情况,包括每个分支的详情
- 缺点:因为每次merge会自动产生一个merge commit,分支很杂乱
rebase
- 会合并之前的commit历史
- 优点:得到更简洁的项目历史,去掉了merge commit
- 缺点:如果合并出现代码问题不容易定位
git add .
git rebase --continue
网友评论