Poojan (Wagh) Blog

Requests for comment

How not to go back in time using git (equivalent of svn revert)

without comments

Update: I recovered my lost commit by following the directions here. In addition, I had to create a branch from this commit using chekcout -b. I then switch to the master branch and merged the temporary branch into master

It has been written posted that git revert is not the same as svn revert. That’s true.

However, there have been suggestions that the equivalent is git reset --hard commit. I just did this. It isn’t good. Luckily, I didn’t lose muchany data. However, doing a --hard means that you reset the index back in time, too–not just your working copy.

I’ll admit that I don’t understand git very well. I’m not entirely sure (now that I’ve gone back in time) how to bring myself back to the future.

Essentially git reset means that you want to get rid of changes in your repository: not merely go back in time, see what things looked like, and move forward in time.

Anyway, a safer thing (for me to have done) would be git checkout commit.

The git manual specifically says:

–hard

Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since commit are lost.

Wonder if I’m too feeble to be MacGyver and need a James Bond. On the other hand, now that I’ve learned this lesson, maybe I’m better off sticking here.

Written by PoojanWagh

May 18th, 2009 at 10:12 am

Posted in Desktop Computing

Tagged with

Leave a Reply