git merge
從feature分支合並到master分支
$ git checkout master
$ git merge feature
Auto-merging Document
CONFLICT (content): Merge conflict in $codefile
Automatic merge failed; fix conflicts and then commit the result.
你可以手動解決$codefile沖突,或者
$ git checkout --ours $codefile
選擇master的版本來解決沖突
$ git checkout --theirs $codefile
選擇feature版本來解決沖突
然后添加沖突文件為已解決並繼續
$ git add $codefile
$ git merge --continue
[master 5d01884] Merge branch 'feature'
git rebase
let's rebase conflicting branch feature
over master
解決master變基時feature分支
$ git checkout feature
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: a commit done in branch feature
error: Failed to merge in the changes.
...
either fix the conflict manually by editing $codefile, or use
$ git checkout --ours $codefile
選擇master分支版本來解決沖突
$ git checkout --theirs $codefile
選擇feature分支版本來解決沖突
然后解決沖突,繼續
$ git add $codefile
$ git rebase --continue
Applying: a commit done in branch feature