[Xcb] git rollback question

Ian Osgood iano at quirkster.com
Thu Apr 27 12:58:55 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Apr 27, 2006, at 12:21 PM, Carl Worth wrote:

> 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

Thanks, Carl! Your git advice is always very calming and well  
written.  (Have you considered writing a book about git?)

What eventually worked was this combo:

% git-reset --hard    # undo the git-pulls which caused the conflict
% git-reset HEAD~1    # undo my last commit (but my local changed  
files are still there)
% git-checkout -f     # blast the local files
% git-pull            # back to the present mainline.

At each step, I verified the current shape of my local main tree with  
gitk.

The scenarios for using git-reset at http://www.kernel.org/pub/ 
software/scm/git/docs/git-reset.html (undo a merge or pull) were also  
very helpful.

Ian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEUSKFHDwFgzc3zyIRAkwSAJ4h5g9UgTi/T9gG+GQQS4ySzexEjQCfRefS
w0Q1i+ox8GsjU5oGnteYimQ=
=qnaI
-----END PGP SIGNATURE-----


More information about the Xcb mailing list