Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In TortoiseGit, which one is MERGE_HEAD and which one is HEAD?

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

like image 868
Mi Po Avatar asked Sep 20 '18 18:09

Mi Po


People also ask

What is Merge_head and head?

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.

Which is head in rebase?

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).

What is merge head in Git?

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.


2 Answers

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.

like image 153
torek Avatar answered Oct 18 '22 21:10

torek


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.

like image 36
A. Genedy Avatar answered Oct 18 '22 19:10

A. Genedy