git 如何显示冲突文件夹_如何解决在git中重命名文件夹的冲突?

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?

解决方案

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

git checkout -b _tmp Branch1

git mv folder BAD_folder && git commit

git merge Branch2

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值