[Xcb] git rollback question

Carl Worth cworth at cworth.org
Thu Apr 27 12:21:29 PDT 2006


On Thu, 27 Apr 2006 11:59:29 -0700, Ian Osgood wrote:
> 
> I made similar changes as Jamey to fix deprecations, resulting in  
> conflicts that I can't figure out how to resolve. Is there a way to  
> rollback a local commit so I can sync back up with the main XCB  
> repository?

The commit itself is permanent.

What can move are the branch references that just point to commits.

Usually, your branch references are just moved "forward" linearly by
git-commit.

But the branch reference is really just a pointer and it's quite easy
to move it around arbitrarily.

The only real danger in doing this is that if you move a reference
away from a commit and you don't have anything else referencing it, (a
child commit, another branch, a tag, a scrap of paper with the sha1,
etc.), then it can be difficult to find the commit again. So you might
want to just do a "git tag before-reset" or so just in case.

With all that explanation and caution out of the way, the way to move
your current branch reference around is actually quite easy:

	git reset elsewhere

(where elsewhere is something that can be resolved to a commit
object).

If you've got some local modifications, then git-reset will kindly
balk at losing them. But if you really do want to drop them, then you
can do:

	git reset --hard elsewhere

Finally, there are a bunch of convenient shorthands for finding
references based on the parentage of commit objects. See the
documentation of git-rev-parse for details, but one example is HEAD~1
which gives you the immediate parent of the commit referenced by the
current branch. So "rolling back" a single commit might look very much
like:

	git reset HEAD~1

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/xcb/attachments/20060427/20e86544/attachment.pgp


More information about the Xcb mailing list