Newbie git experience: resetting local git tree back to an
earlier state
Mike McCormack
mike at codeweavers.com
Sat Apr 29 23:36:04 CDT 2006
Dan Kegel wrote:
> I gather the right command for this is "git reset", so I read the man page.
> It wants a "commit-ish" as the argument. (Boy, that's helpful.)
> Looking at that patch, I saw its filename was an md5 sum, so I figured
> maybe that was the "commit-ish", and tried
>
> $ git reset --soft b32ae7a40c601427fea7cb9f145138221030f869
> fatal: Needed a single revision
You can get a "commit-ish" SHA-1 IDs for your tree using "git
whatchanged".
A commit is an SHA1 ID of the commit it was based off, the patch
committer's name+email, the patch author's name+email, the time of the
commit and the root directory of the tree committed.
Since James's tree had him as the committer, and my tree has me as the
committer, the SHA1 IDs won't be the same. If I were to pull/merge his
tree, then they would be.
> $ git reset --soft HEAD~8
>
> And voila, it worked; "git log" now showed the desired change as
> the latest!
> (Whew. I thought I was going to drown in man pages for a while there.)
>
> Annoyingly, "make" did nothing after this, but I knew the changes
> I wanted to revert were all in one DLL, so I just removed that DLL's
> .o files and ran make again.
"git reset" as used above will only modify the commit history. "git
diff" should now show you the diff between the old HEAD and the old HEAD~8.
You can use "git reset --hard" to change the checked out tree too, but
it will reset it to the point you specify, and you will lose any changes
not committed at that point.
So, to reset your whole tree (commit log and checked out files) to the
state it was just after the previous commit, you do:
git reset --hard HEAD^
> I feel a bit more comfortable with git now!
Great! It's a bit of a hard slog at first, but as more people get used
to GIT, then it should be easier to get help.
You've probably see this already, but incase others haven't the Wine
Wiki has a page on GIT here:
http://wiki.winehq.org/GitWine
Mike
More information about the wine-devel
mailing list