Erik B
Erik B

Reputation: 349

How to resolve merge conflicts in a branch without actually merging?

I have 3 branches: master, develop, and hotfix-12345.

hotfix-12345 is branched off of master, but needs to be merged into develop.

So I

git checkout develop

git merge --no-ff hotfix-12345

And my merge conflicts appear. Okay, so (in Visual Studio Code) I "Accept Incoming Changes" for the files that have conflicts, and save. But I'm on develop, so these changes are only fixed in develop, not the hotfix branch, and I can't push the develop branch, it has to be the hotfix branch. So trying to merge my local hotfix-12345 into origin develop will still give merge conflicts.

If try to merge the reverse (develop into hotfix-12345), unstage everything except the merge conflict files, resolve the conflicts and save them, they don't appear in git status as modified files.

How do I find the merge conflcits in hotfix-12345 with develop & resolve them without actually merging develop into hotfix-12345 ?

Upvotes: 3

Views: 6269

Answers (1)

VonC
VonC

Reputation: 1323115

How do I find the merge conflcits in hotfix-12345 with develop & resolve them without actually merging develop into hotfix-12345 ?

One possibility would be to rebase the hotfix branch on top of origin/develop: you can resolve conflict there, and then revert some of the origin/develop changes you do not want in hotfix.
Once that selection is done, you can push hotfix, while develop remains local and untouched.

git checkout hotfix
git rebase origin/develop
git rebase 

Upvotes: 1

Related Questions