开发者

Git conflicting commits

I'm wo开发者_高级运维rking in a multi-user git environment. My workflow is to work in a branch, and pull from the remote into local master, then rebase my working branch, merge the branch with local master, then push to the remote repo.

In the most recent pull there 6 new commits, one of them my code needs to take precedence over.

If I rebase, I'll need to resolve several conflicts, and then replace existing objects with my own. I can do that, but it seems pretty manual, and begging for problems.

What's a better way to handle this?


You can git revert the bad commit in the master branch, and then rebase to your topic branch:

git checkout master
git revert <sha1>
git rebase master topic


I'm not sure there is a better way. If two commits conflict then you have to tell git how to resolve it.

Your question suggests that it's a little bigger than that, though. It sounds like you've done "framework A with supporting object B" and the mainline has done "framework C with supporting object D" and you want to discard C&D in favour of A&B. Is that correct?

If so, then you're still stuck with the same problem: you need to decide what to tell git. If new code has supplanted old code then git can't know unless you tell it.

Ultimately, you'll have to either rebase or merge and both will have the same set of conflicts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜