Newbie git experience: resetting local git tree back to an earlier state

Dan Kegel dank at
Sat Apr 29 19:21:18 CDT 2006

This is a little success story.  I thought I'd post it to encourage other
people to try Mike's tree via git.

I just started using git so I could track Mike McCormack's tree.
I first followed the instructions at
to get a winehq tree, then followed Mike's instructions at
to grab the latest changes.

The commands I used on my Ubuntu box were, all in all:

sudo apt-get install git-core git-doc
git clone git:// wine-git
cat > .git/remotes/mmbranch <<EOF
Pull: refs/heads/master:refs/heads/mmbranch
git fetch mmbranch
git pull . mmbranch

Everything went smoothly; it was rather fabulous.
Then I ran into a regression, and wanted to roll back to Mike's tree as
of a certain patch,

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

Crud.  At this point I punted, sent an email to James asking for help,
ate a cookie, and periodically re-read google and the man pages.
Eventually it dawned on me that you can specify a particular commit
by how many back from the head it is, e.g. HEAD~5 is 5 back from
the tip.  I also stumbled on the command "git log", which shows you
all changes, most recent first.  Sure enough, the change I wanted was
eight back from the head.  So I tried

$ 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.

I feel a bit more comfortable with git now!
- Dan

More information about the wine-devel mailing list