So fellas, it's been a while since I wrote and I hope this article is of help to whoever reads this.
Let's start with bit of an introduction. Until my previous employment, there wasn't much guideline on how we write Github's commit message. One single feature could have n number of commits and it doesn't bother the repository.
Now, am part of @webex's webex-js-sdk team where committing guidelines are very strict and having a bit more deep knowledge of git commands has become essential. This made me explore git commands on regular basis. So I thought why keep them to myself while I can share them.
It was my first ever PR and my changes were approved except for a few minor changes. I honestly didn't know how to make changes to existing commit and now, I had two choices.
- Create a new branch from master and re-do the work manually
- Do some git magic and make the current branch work well.
* Please read this post fully before executing any command. My scenario might not be same as yours.
git reset --hard
- Backup your changes
- Do git log
- Scroll down to the commit until which you want to remove the history.
- Copy it's commit hash and execute the following command -> git reset --hard <copied_commit_hash>
- For instance, git reset --hard 54ace3456ka235rtyc90