Reputation: 8855
Let's say I have two branches
I want to merge the changes in A
to B
. However, A
has some files that I changed as well as some files that someone else changed. For example, in A
, there are 2 files that changed.
On merging from A
to B
, I find that there are conflicts with the file that someone else changed (in the running example, JavaFile2.java
). Now, I want the merge to proceed so as to
I am not sure if a resolution of using mine
or theirs
is appropriate, because on the next merge, it might never consider the conflict again (git will mark the conflicts as resolved in future merges).
I suppose I can cherry-pick too, but on our team, we have a policy to merge
forward (e.g. from A
to B
) and cherry-pick backwards (e.g. from B
to A
).
Is it possible to do as I stated? We also have a policy that a developer must merge their own commits, but, unfortunately, this developer is not available for the next two weeks (vacation).
Upvotes: 1
Views: 36
Reputation: 520888
For me the conceptually easiest way to deal with this would be to perform the merge and then reset the file in question to the commit in B
which was at the HEAD
of that branch before the merge.
The command you would use to reset the file modified by another user is:
git checkout <SHA-1> path/to/another/JavaFile2.java
where <SHA-1>
is the hash of the most recent commit on B
before you did the merge (i.e. the version you want to keep).
If there is a merge conflict in this file during the merge, then you can reset it using the above command and commit. If the merge completes without a conflict, then you can still run the above command, and you can amend the merge commit:
git add path/to/another/JavaFile2.java
git commit --amend
Upvotes: 2