Git - Remove in between commit

Viewed 23442

Our team is doing several projects in PHP. We have wrongly committed a folder of One Project to another. Now, we want to remove that particular commit from the Project. If we remove the particular folder/commit from the project then there is no issue for our project.

If we just remove the folder and issue the new commit at the current position then the folder is removed but it will remain in the history of Git. So, we want to remove it completely from refs, history and other things from Git.

We can also create a separate branch but the commit refs of authors would be lost. We want to only remove that particular commit. We have no issue in rewriting history or re-basing it but don't know how to do it.

In the project we have done 136 commits and want to remove commit no.76th. The required information about SHA is as under

5d39775b          //136th commit
a4df5ee9          //135th commit
6971cf35          //134th commit
.....
....
162f833c          //76th commit
32603274          //75th commit
.....
....
9770059          //1st commit
6 Answers
Related