I am using git repository in my project. I have accidentally pushed 2 commits which I shouldn't have. And in between some one has committed on top of it. Is it possible to remove my pushed commits or I have to remove my code changes and push it as new commit, since some one has committed on top of it.
Git Master branch :
Commit A // by me
Commit B // by me
Commit C // by some one
Now I have to delete Commit A and B leaving Commit C. Any help will be really appreciated.
git reset --hard HEAD~1
Where HEAD~1 means the commit before head.
Alternatively find the commit id of the commit you want (look at the output of git log), and then do this:
git reset --hard <sha1-commit-id>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With