Iago-lito February 2016

Artificially make one commit point to another one after manual merge?

I was in such a git state:

after git checkout outer:

* 2df9c6b (HEAD -> outer) Ready for merging
* 161c98f Working on new stuff..
* faec47b Welcome to branch `outer`
* d2166d0 last common commit
...

after git checkout master:

* 82c6303 (HEAD -> master) Go on doing stuff
* d2166d0 last common commit
* ...

After having run git merge outer with no conflicts, I came out with something like:

* 6ebd696 (HEAD -> master) Merge branch 'outer' into master
|\
| * 2df9c6b (outer) Ready for merging
* | 82c6303 Go on doing stuff
| * 161c98f Working on new stuff..
| * faec47b Welcome to branch `outer`
|/
* d2166d0 last common commit
...

However. The automatic merge turned out not to be what I actually wanted to have. So I ran git reset 82c6303 --hard to start over with:

git merge outer --no-commit
... fixing stuff, merging on my own ..
git add *
git commit -m "Merged branch 'outer' into master"

What I have now is:

* 3d1250b (HEAD -> master) Merge branch 'outer' into master
* 82c6303 Go on doing stuff
* d2166d0 last common commit
* ...

Which is: commit 3d1250b is like I wanted it to be, but it does not point to 2df9c6b anymore. How can I make it point to 2df9c6b in order to make it clear what happened? Would it even mean anything?

Answers


David Deutsch February 2016

So unless you did something funky between git merge outer --no-commit and git commit -m "Merged branch 'outer' into master", I have no idea why your commit was not recorded as a merge commit (i.e. why it doesn't have two parents). But, assuming that 3d1250b really contains the snapshot as you would like it after the merge, the following will make an "empty" commit that points to 3d1250b and 2df9c6b, which is a "correct" history: git merge outer --strategy ours.

Post Status

Asked in February 2016
Viewed 2,465 times
Voted 10
Answered 1 times

Search




Leave an answer