Wrong Git Commit ? Don’t Worry — This Command Will Help

Pratiyush Prakash
3 min readDec 28, 2021

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 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.

Interactive window

Here you can see, my incorrect commit is showing up. There are also various commands you can see and each one have a description…

--

--

Pratiyush Prakash
Pratiyush Prakash

Written by Pratiyush Prakash

Solution Architect and Full stack Developer @ Texas Instruments. Follow me for short articles on software development.

No responses yet