Wrong Git Commit ? Don’t Worry — This Command Will Help
Git has become an essential part of our life. Whether you work in big multinational software company or an early stage startup you must learn how to use git. And don’t feel that you are alone, we have all been through the journey and it is scary when you are new to the company and you messes up a git commit and now you don’t know what to do.
Don’t worry, there is a very simple way to resolve it. Let’s jump right into it.
GIT COMMAND
Let’s understand this through an example.
Let’s say you made this commit but unfortunately there was a typo in the message, so let’s see how we can fix the message or entirely drop the commit.
git rebase -i HEAD~2 // -i is for interactivity
// the number is configurable, how many commits do you want to refactor.
When you run this command, a very intuitive window will appear which will ask you what exactly do you want to do with these commits.
Here you can see, my incorrect commit is showing up. There are also various commands you can see and each one have a description…