Question

Is there a way to have Git force a manual resolution for a file when the file was edited in both branches?

My problem is that I want some of the changes from one branch and some of the changes from the other. It turns out these changes don't always step on each other but the algorithm is not always picking the correct change.

One thing I notice, is the base file in the 3-way merge isn't what I was expecting. Is it possible to have Git use a chosen file from one branch as the base?

No correct solution

OTHER TIPS

If git detects conflicts in a file it will always ask you to edit (or use a merge tool) to fix the conflicts. In this case you can fix it up however you like before staging it.

If git hasn't detected conflicts in a particular file but has detected conflicts elsewhere, then you can always fix that particular file and add the fixes (git add) before making the merge commit.

In this case you can access the two different parent versions of the file via git show HEAD:path/to/file and git show MERGE_HEAD:path/to/file. You can redirect the git show output to temporaries if you want to open them in an editor, say.

Once you've fixed up the file and resolved any other conflicts you can stage the fix (git add) and make the merge commit (git commit).

If git didn't detect any commits it will make the merge commit with no further prompts.

In this case you can still fix up your file. The two parent versions are accessible via git show HEAD:path/to/file and git show HEAD^2:path/to/file.

Once you've fixed up the file you can stage (git add) and redo the merge commit with git commit --amend.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top