2012-11-09 113 views
3

我已經從現有的分支創建一個新的分支:混帳合併重命名衝突

git checkout master 
git checkout -b test 

然後在新的分支,我改名文件:

git mv foo.txt fooOld.txt 
git mv fooNew.txt foo.txt 
git commit -am "Rename file" 

與此同時其他人已經編輯了主分支上的fooNew.txt並推送更改:

git co master 
echo "Some changes" >> fooNew.txt 
git commit -am "Do some important changes" 
git push origin master 

現在,當我嘗試並從mas中提取更改時之三,我得到一個錯誤:

CONFLICT (modify/delete): fooNew.txt deleted in HEAD and modified in master. 

我怎樣才能讓我結束了含有做fooNew.txt上主的變化foo.txt的文件合併這2個分支?

+1

你在'git pull'命令之前把'test'合併到''master'了嗎?否則,將'master'合併到'test',解決衝突,然後合併回'master'。如果已經合併,那麼您需要事先將主服務器恢復到之前的提交狀態。 – JScoobyCed

+1

您是否嘗試重新綁定? 'git pull --rebase origin master' – iltempo

+0

謝謝,我已經嘗試過'git pull --rebase origin master'並且首先合併測試,但是我仍然遇到同樣的問題,可以通過保存修改來解決衝突foo.txt文件或刪除它。我也嘗試用測試rebasing大師,但沒有運氣... – tempestSA

回答

0

使用你的方法,我沒有問題。

$ git checkout -b test 
Switched to a new branch 'test' 

$ git mv foo.txt fooOld.txt 

$ git mv fooNew.txt foo.txt 

$ git commit -am "Rename file" 
[test bf82f6d] Rename file 
1 files changed, 0 insertions(+), 0 deletions(-) 
rename fooNew.txt => fooOld.txt (100%) 

$ git checkout master 
Switched to branch 'master' 

$ echo "Some changes" >> fooNew.txt 

$ git commit -am "Do some important changes" 
[master 653c0df] Do some important changes 
1 files changed, 1 insertions(+), 0 deletions(-) 

$ git checkout test 
Switched to branch 'test' 

$ git merge master 
Auto-merging fooOld.txt 
Merge made by the 'recursive' strategy. 
fooOld.txt | 1 + 
1 files changed, 1 insertions(+), 0 deletions(-)