I was looking to learn a bit more about the parts of git I’ve not ventured into yet. What better way that looking the most common ways people screw them up and how to fix the resulting problems! Here’s a short list, compiled from my own experience and issues I’ve come across on the Internet.
I wrote the wrong thing in a commit message
If the commit hasn’t been push you can do the following, which will allow you to edit the message on the most recent commit:
git commit --amend
How can I undo the last commit?
You can use git reset e.g.:
git reset --hard HEAD~1
HEAD~1 means HEAD-1 commit. It should be noted that this is the nuclear option, and any changes you made will be discarded. If you want to keep your changes in the working tree use:
git reset --soft HEAD~1
If you’ve already published…
View original post 593 more words