Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: how to roll back to last push/commit

I am programming. I add beautiful code and commit and push it to my repo like:

git add * git commit //writes message git push unfuddle master 

Now i go in and screw everything up. I have not issued a git command since I push the beauty. How do i make my local files go back to what was committed?

git pull says my local repo is "up to date"

git checkout spams out my screen and doesnt seem to change anything.

To be clear: I am not trying to modify my remote repo, just get my local repo to look like the server.

My current solution is to delete the folder and reclone the repo. That can't be right.

like image 510
Mikey Avatar asked Feb 17 '12 21:02

Mikey


People also ask

How do I roll back the last commit?

The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.

Can we revert the last commit in git?

The revert command You can find the name of the commit you want to revert using git log . The first commit that's described there is the last commit created. Then you can copy from there the alphanumerical name and use that in the revert command. In this image, each circe represents a commit.


1 Answers

You can reset to HEAD: git reset --hard HEAD

like image 110
three Avatar answered Oct 20 '22 15:10

three