This is an easy question, but git is really confusing with it's labels, and I couldn't find an answer.
When I have local changes and I want to merge the latest remote repository into my local repository, I do a local commit and then git pull.
When the merge conflicts show up, I have the option to resolve conflict using MERGE_HEAD and to resolve conflict using HEAD
Which one is the remote repository and which one is the local repository?
Thank you
HEAD is your current branch, which means the one you have checked out now. For git merge that's the one you had checked out when you started. MERGE_HEAD is the other commit, which means the hash ID of the commit you told Git to merge.
But during the rebase, HEAD is either their branch-tip (commit L ), or one of the new commits copied and appended past their branch-tip; and --ours means the branch being grown at the end of L while --theirs means the commit being copied-from ( G or H above).
The "merge" command is used to integrate changes from another branch. The target of this integration (i.e. the branch that receives changes) is always the currently checked out HEAD branch. While Git can perform most integrations automatically, some changes will result in conflicts that have to be solved by the user.
They are both local (this is important, albeit not very helpful :-) ).
HEAD
is your current branch, which means the one you have checked out now. For git merge
that's the one you had checked out when you started.
MERGE_HEAD
is the other commit, which means the hash ID of the commit you told Git to merge. That is, git merge origin/master
resolves origin/master
to some local commit hash ID, and then merges that commit, and MERGE_HEAD
contains the hash ID of that commit.
I think a better term for the other commit is other or --theirs
, and Git sometimes uses those terms, but other bits of Git do use the term remote to refer to the --theirs
commit.
I stumbled upon this thread while searching for the same issue. I use WinMerge as the merge tool for TortoiseGit, and when resolving a conflict, it displays 3 panes: MERGE_HEAD
to the left, Base
in the middle, and HEAD
to the right.
Turns out that the MERGE_HEAD
is the commit/branch you are trying to merge, HEAD
is the commit/branch you are trying to merge to, and Base
is the merge result that you should edit in order to resolve the conflict.
So, you should edit the code in the middle pane, Base
, save it, and commit.
Update 11/11/2021: This answer is inaccurate .. see below comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With