[Xcb] removing latest commit

Eric Anholt eric at anholt.net
Wed Feb 21 13:55:00 PST 2007

On Wed, 2007-02-21 at 13:33 -0800, Jamey Sharp wrote:
> On Wed, Feb 21, 2007 at 09:18:29PM +0100, Vincent Torri wrote:
> > My latest commit was wrong (my randr proto was not up to date)
> > 
> > how do I use git rest to remove that commit ?
> In general, the answer is "make sure it's right before you push." ;-)
> As long as you coordinate with other people to make sure nobody's
> changes get lost, though, you can
> 	git-reset --hard HEAD^ # remove the last commit locally
> 	git-push -f origin # make remote exactly match your local tree

Please don't recommend that.  Usually, that'll reset all of the remote
branches for which there is also a local branch.  Easy scenario for
breakage: I manually fetch out someone's branch without putting it in my
remotes file, then they did more development, then I do your git-push to
reset master that I messed up on.  Much safer (though still nasty) to

	git push origin +branchname:branchname

That will just reset the one branch you wanted to.

> Be careful! If anybody else has committed, this will erase their commits
> too! And if anybody else has done a git-pull since you pushed the bad
> commit, they'll have to `git-pull -f`, which can erase their local
> commits. It's bad all the way around.

So, unless there's a really good justification (like you pushed
something with incorrect copyright on it or something, or maybe just if
you did a branch merge that shouldn't have happened and it'll interfere
with future merging), then I would recommend just doing:

	git-revert HEAD # revert the last commit
	git-push origin master # push your reversion

The history then continues to have the mistake and the reversion in it.
Oh well.

Eric Anholt                             anholt at FreeBSD.org
eric at anholt.net                         eric.anholt at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/xcb/attachments/20070221/89fb9116/attachment.pgp

More information about the Xcb mailing list