I know there are lots of questions on SO about this, but I can't seem to find the answer I'm looking for at all.
I just merged my task branch into my master, and I am ready to push my changes to the remote master branch. However, they are displaying as two commits:
commit 878c07412aab6a6b06b7fc8dd84c2418cc4f31d8
Merge: 9ffa590 c9f5552
Author: ***
Date: Mon May 21 16:02:36 2012 +0100
Merge branch 'modelUpdate4'
Conflicts:
***.xcodeproj/project.pbxproj
commit c9f5552862872673317701c3dffd7fb6b6daa02c
Author: ***
Date: Mon May 21 15:03:21 2012 +0100
Modified model according to requests. Repopulated seeded database.
This is the output of git log and the two commits I wish to squash as one. However, when I do:
git rebase -i HEAD~2
It actually just displays 4 previously committed (and pushed) commits. Am I misunderstanding how my branches are merged back? If I try and git rebase -i This just displays the first commit in the git log list.
Thanks!
Since you said four commits were already pushed, I'm guessing your graph (
git log --oneline --decorate --graph
) looks something like this, where you've got branching commits betweenmaster
andmodelUpdate4
already pushed to the remote repo:HEAD~2
is the first parent of the first parent, and since yourHEAD
is a merge ofmodelUpdate4
intomaster
, it refers to two commits down themaster
line.HEAD^2
isHEAD's
second parent, so the commit beforeHEAD
down themodelUpdate4
line. (See also: http://paulboxley.com/blog/2011/06/git-caret-and-tilde)If
HEAD~2
is your new base, you'll get all the commits betweenHEAD~2
andmaster
in a straight line. You'll also have to deal with the branch conflict in themodelUpdate4
commit where it happens.If anyone else is using those remote branches, or you want to maintain your branching history, don't rebase. It'll rewrite history that's already in the remote repo, which will just be a headache for everyone else. Push the merge commit out and you'll be golden.
Alternatively, you could rebase directly onto
origin/master
.origin/modelUpdate4
would end up out in the git boonies, but since it's a task branch I'm betting you were just going to delete it anyway.