How to resolve conflict of renamed folder of file in git?

允我心安 提交于 2019-12-13 15:40:33

问题


I have following problem:

I have some common commit A for two branches Branch1 and Branch2.

  • Branch1 is a public branch (lies on server)
  • Branch2 is a local branch

In Branch1 I changed file (BAD_folder/somefile.txt). Changes were pushed to server. In Branch2 I renamed BAD_folder to folder and made some changes in somefile.txt. I want to merge Branch1 with Branch2, but I get a merge conflict in BAD_folder/somefile.txt file.

How can I resolve this?


回答1:


You can rename folder to BAD_folder, merge or rebase Branch2 (which might be better when this branch is local) and rename folder back.

  1. git checkout -b _tmp Branch1
  2. git mv folder BAD_folder && git commit
  3. git merge Branch2
  4. git mv BAD_folder && git commit

When you did a rebase, you can do an additional git rebase -i Branch1 and remove the two git mv operations.

merge in point 3 works much better when filenames did not change but you might still have to resolve conflicts.



来源:https://stackoverflow.com/questions/39293530/how-to-resolve-conflict-of-renamed-folder-of-file-in-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!