Justin Meltzer
Justin Meltzer

Reputation: 13548

How to get back to the last commit after making some changes?

I've made a couple of changes on my local files but I have not commit or added any of them. I want to go back to my previous commit before this recent changes. How can I do this?

Upvotes: 1

Views: 137

Answers (3)

Adam Dymitruk
Adam Dymitruk

Reputation: 129526

git reset --hard

will remove those changes.

However, just in case, I would add them

git add -A

and then stash them

git stash

Just in case you regret your decision. The last 2 commands can be shortened to:

git stash -u

Upvotes: 2

Morgan Cheng
Morgan Cheng

Reputation: 75998

try "git checkout -- files_to_revert "

Upvotes: 1

maraspin
maraspin

Reputation: 2393

git checkout might do the job for you. You should be able to do something like:

git checkout FILE_TO_REVERT

Upvotes: 1

Related Questions