Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - How do I revert my local files to the last commit i made?

Tags:

git

bitbucket

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?

like image 451
Manuel da Costa Avatar asked Nov 30 '25 00:11

Manuel da Costa


1 Answers

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

like image 171
aragaer Avatar answered Dec 02 '25 15:12

aragaer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!