I have merged two of my branches (using the Eclipse merge tool).
When I commit, the commit has only one of the branches as parents (the original workspace HEAD). I’ll dig into why that happens later, but I need to commit this properly right now (there was lot of work involved in the merge).
How can i amend the commit to include the reference to the other branch? The file contents are all good now, I just want to have the commit have two parents.
First, if you have already committed, run
git reset --soft HEAD^to undo it.Method 1
Create
MERGE_HEADfile inGIT_DIR(usually/.git) which containsSHA-1of the tip of the branch (you can get it usinggit show-ref) you are merging with (and an empty line, just to mimicgit mergebehavior). And commit as usual.Method 2
Also, you can do it without messing with git internals, if you prefer:
.gitdirectory) somewheregit reset --hardgit merge branch_to_merge_with --no-commit.gitdirectory)P.S. it could happen if you’ve used
git merge --squashoption orMERGE_HEADfile was lost somehow.