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.
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.
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.
You can reset to HEAD: git reset --hard HEAD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With