Home  >  Q&A  >  body text

Git中把自己的本地版本库推送到远程版本库后,怎么撤销?

如题,如果把一个错误的修改推送了到远程的版本库后,有什么办法可以撤销这次的推送?

过去多啦不再A梦过去多啦不再A梦2727 days ago679

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-05-02 09:28:27

    You should only be able to roll back the version of your local repository and push it again.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:28:27

    Just roll back to the previous commit id and push again, but there will still be records on the remote end

    reply
    0
  • PHP中文网

    PHP中文网2017-05-02 09:28:27

    Submit after revert, but there will be two commits in the history record that are useless. A wrong commit, a commit revert this wrong commit

    Of course you can also use reset, such as git reset --hard <commit hash>, and then add -f when pushing to force an update. But this operation is very dangerous. If someone else has checked out your wrong commit and you reset it, others will have errors next time they pull or push.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-02 09:28:27

    1.Reset first

    git reset HEAD^
    

    2. Modify and then commit

    3. Force submission again in an evil way. . .

    git push --force

    reply
    0
  • Cancelreply