3

I host my files on bitbucket and normally commit changes every now and then.

Since my last commit, I have made some mistakes in my code.

(These mistakes have been saved in their respective local files and I haven't added it to the local git repo just yet using git add.)

I would like to revert back to my last commit with the working code. I am currently working on a branch off the master.

What command should I use for this?

5

2 Answers 2

1

git reset --hard will revert all files to HEAD. I prefer this to git checkout -- . but that's just a matter of preference.

1
  • I tried this git reset --hard ab53ga3s and it reverted my files to the ab53ga3s commit Jan 12, 2013 at 23:12
1

For a file: git checkout -- filename also git checkout -- directory/ will do this for the entire directory and of course git checkout -- . for the entire repository.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.