change a git commit already pushed

This question already has an answer here:

  • How to delete commit that is pushed to the remote repository? 3 answers
  • How to undo the most recent commits in Git? 69 answers
  • Delete commits from a branch in Git 23 answers

  • By default, remote servers will disallow overwriting already pushed commits. This is because those new commits are different objects which are incompatible to those published before. This means that anyone who has already fetched from the remote since will have major problems fixing it once you overwrite the commit. So you should really reconsider overwriting the commit with something else. Note that git revert works with merge commits too, so you might want to consider that instead.

    That being said, you still can push that rewritten commit even if it conflicts with what's on the server. You can do that by force pushing using git push --force or git push -f in short.

    链接地址: http://www.djcxy.com/p/574.html

    上一篇: a,如何恢复它

    下一篇: 改变已经推送的git commit