Hesam Hesam - 2 months ago 5
Git Question

How to remove some commits from middle of git master branch?

I have committed to master branch mistakenly and unfortunately other devs have committed their changes on top of it. So I want to remove all of my commits. This is my commit list:

enter image description here

I want to delete all commits on 20 Aug 2016. What is your recommendation? Thanks

git rebase -i ca83eb3

When the interactive rebase happens, your text editor will come up. change pick to drop for the five commits you made. This will drop the commits from history after you save and exit the editor.

Of coarse we could do some bash with logging the sha with only commits from you on that day, but since it is only 5 commits, let's just do this easy rebase.


You should not do this. Now that your commits are public, every developer’s code will have to be reset once you change history of their remote. Instead, consider leaving it, or making an additional commit that removes your code. You don't want to change history on public branches.