[m-dev.] Merge commits

Paul Bone paul at bone.id.au
Fri Jan 11 14:52:14 AEDT 2013

On Fri, Jan 11, 2013 at 02:33:58PM +1100, Peter Wang wrote:
> Hi,
> If you try to push some changes and git tells you that you're not up to
> date, please use "git pull --rebase" (you can make it the default).
> By default, "git pull" will merge, complicating the history (see gitk)
> and making it harder to work with.

On this note there's also some useful features here.  Lets say you have a
typeo in your last commit or it's log message.  no-problem!  fix the typo
and do a "git commit --amend"  (I've you've 'pushed' your typo then it's too
late, this is only if you've not pushed yet).

Simiarly, what if your typo is two commits ago (and you havn't pushed either
of the last two commits yet).
Create a new commit fixing your typo, and the edit the history of the last
three commits (this is why you have to do this before you push, because it's
editing history):

git rebase -i HEAD~3

Edit the order of the commits, delete commits, mark commits as 'squash' (they
get merged with their previous one).  or 'fixup', the same except the log
message is discarded (for typeos).

It takes some getting used to, when you're done check your work with gitk
before you push.

Oh, and if you ever make a mistake look at: git reflog, find a ref before
your mistake, and reset your branch to that point, I forget the easiest way
to do this.

Paul Bone

More information about the developers mailing list