I would like to know how to delete a commit.
By delete
, I mean it is as if I didn\'t make that commit, and when I do a push in the future, my changes wi
Say we want to remove commits 2 & 4 from the repo.
commit 0 : b3d92c5
commit 1 : 2c6a45b
commit 2 :
commit 3 : 77b9b82
commit 4 :
Note: You need to have admin rights over the repo since you are using --hard
and -f
.
git checkout b3d92c5
Checkout the last usable commit.git checkout -b repair
Create a new branch to work on.git cherry-pick 77b9b82
Run through commit 3.git cherry-pick 2c6a45b
Run through commit 1.git checkout master
Checkout master.git reset --hard b3d92c5
Reset master to last usable commit.git merge repair
Merge our new branch onto master.git push -f origin master
Push master to the remote repo.