1

I have an ongoing merge which I did not finish - the repo is still in "MERGING" status, the MERGE_HEAD file exists. I now do not know anymore which revisions it is that I am trying to merge - well, via git log I know the name of the revision and branch that I am on, so I know that parent - but it's the other (future) parent I'm missing.

Of course the command history in my console is not long enough to still contain the git merge command I used - it's long forgotten.

git status only tells me : "All conflicts fixed but you are still merging.".

Charles
  • 988
  • 1
  • 11
  • 28
  • Possible duplicate of [How to quit (not abort) a Git merge in progress keeping the changes uncommitted?](https://stackoverflow.com/questions/55859458/how-to-quit-not-abort-a-git-merge-in-progress-keeping-the-changes-uncommitted) – kowsky Jul 02 '19 at 10:20

3 Answers3

1

You can use

git log --merge -p

to show a diff of the commits not common to all the branches being merged (source). You can see the commit SHAs of the last commits pointed by the branches there.

EDIT: You can also print the commit identifier you're merging with using cat .git/MERGE_HEAD

Álvaro Pérez
  • 321
  • 3
  • 9
  • I'm not sure I understand, but I think `git log --merge` and looking at the top commit would be an answer. – Charles Jul 02 '19 at 11:30
  • 1
    @Charles The command `git log --merge` would show you the list of commits that are unique to each branch (being merged), and unless you are merging to or from a commit that it isn't the last of its branch, you can identify both branches by looking at the branch names at the end of the commit identifiers. (e.g. (HEAD -> master), (develop) ) – Álvaro Pérez Jul 02 '19 at 13:10
  • Made a small example, understood everything you said. Pretty great, thank you. – Charles Jul 03 '19 at 09:06
1

The MERGE_HEAD file contains the answer in plain fact. In fact, it contains only that.

If any git command exists to show its content from the console, I'd be glad to know and would distribute points.

Charles
  • 988
  • 1
  • 11
  • 28
-1

to get rid of the status "All conflicts fixed but you are still merging." there is git merge --continue

to abort the current merge (and return to what you call the (future) parent) you could use git merge --abort. That is always a nice option, because you can just start over

to see what happened to your repo before the merge use git reflog every line is one step that git took for you:

Haass@LAPTOP-ETDGT1PT MINGW64 /c/devel/inventory (master)
$ git reflog
398e725 (HEAD -> master, upstream/master) HEAD@{0}: reset: moving to upstream/master
8700bfd (origin/master, origin/HEAD) HEAD@{1}: checkout: moving from 398e72552f3300d0389426b17feae6543305156f to master
398e725 (HEAD -> master, upstream/master) HEAD@{2}: checkout: moving from master to upstream/master
8700bfd (origin/master, origin/HEAD) HEAD@{3}: rebase finished: returning to refs/heads/master
8700bfd (origin/master, origin/HEAD) HEAD@{4}: rebase: checkout refs/remotes/origin/master
be73d62 HEAD@{5}: reset: moving to HEAD

It looks like this. before a merge there always is a checkout, so go from top to bottom and find the first checkout. The first column is the git hash you can use for checkout.

In such situations I like to git tag my steps, so that I can return to any intermediate step whenever i get lost in some git actions

Martin
  • 184
  • 10