How do I reset a bad commit using git on a remote branch?
This question already has an answer here:
Two possible, different solutions:
git revert commit1; git push
git revert commit1; git push
- creates a new commit, which reverts commit 1
git rebase -i HEAD~3
then just delete the commit 1 and git push -f
but note this requires privilege to "force push" which means rewriting history which is not always desirable (do your research, this is typically viable only when working on code that has not been distributed/published/frozen). Refer to man pages for more details.
上一篇: 使用git删除提交