change a git commit already pushed
This question already has an answer here:
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.
上一篇: a,如何恢复它
下一篇: 改变已经推送的git commit