1

I'm working on my project in Sublime text. After reaching a milestone earlier, I committed my work to my local Git (didn't Push)

I continued working, and screwed up. Now I want to go back to my last commit and try again. So I Googled a bit and found the git revert --hard last-commit which I entered in my command prompt and got this

HEAD is now at 5d6eebd Revert "Finished adding feature. Everything works"

But in my Sublime editor, my files haven't changed back. I tried closing and reopening the files but everything is still screwed up.

What's the point of reverting if it doesn't change my files back? Am I doing something wrong?

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
  • `git revert --hard` does nothing and prints out usage for me. Did you actually reset to a commit that happened to be a revert, or did you revert? – Andrew C Nov 13 '14 at 21:25

2 Answers2

0

git revert is for making a new commit that undoes the work of a previous commit (or range of commits).

To get back to your last commit on the current branch, discarding all work done since then, try git reset --hard HEAD.

Thomas Foster
  • 301
  • 1
  • 4
0

What you do with revert it's cancel the commit.

If you want use the branch "5d6eebd" do a checkout.

If not if you want to destroy local changes use reset.

Revert documentation ( http://git-scm.com/docs/git-revert ) says "If you want to throw away all uncommitted changes in your working directory, you should see git-reset[1], particularly the --hard option."

In another thread here you have some samples How to revert Git repository to a previous commit?

Community
  • 1
  • 1