git 解決沖突之 theirs & ours


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 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM