How to push to GitHub after amend

This question already has an answer here:

  • How do I push amended commit to the remote Git repository? 13 answers

  • As pointed out by @Yoginth, you might do git push --force , but it is better (because safer) to do git push --force-with-lease instead.

    The corresponding syntax is described in this handy list of git tips:

    git push --force-with-lease <remote-name> <branch-name>
    

    To be more precise, git push --force-with-lease will refuse to force-push if the remote branch (say, branch master in repo origin ) has commits that are unknown in local branch origin/master


    Use the push --force command to force push over the old commit.

    git push --force example-branch
    

    https://help.github.com/articles/changing-a-commit-message/


    All that said, have in mind that amending a commits previously pushed is a bad practice (bad bad), and it is only safe to do in the case of the branch you're pushing is only yours and not a shared one.

    If someone else pulls from that branch, it could lead to conflicts, and lots of unexpected situations such as:

  • Conflicted merges
  • Overritten changes
  • Headache
  • Joint pain
  • Global warming
  • 链接地址: http://www.djcxy.com/p/48918.html

    上一篇: 如何在Git中添加对提交的更改的修改?

    下一篇: 修改后如何推送到GitHub