How to delete commit that is pushed to the remote repository?

后端 未结 3 1112
你的背包
你的背包 2020-12-15 13:22

A local branch:-

\'feature/100\'

And Remote branches:-

\'master\'

\'Version2\'

Accid

相关标签:
3条回答
  • 2020-12-15 13:43

    It's probably too late, but if you want to rewind your pushed branch (master?) by one commit, issue the following command:

    git push origin +master^:master
    

    + makes the push forced, master^ describes the previous-last commit. :master pushes to the remote master branch.

    0 讨论(0)
  • 2020-12-15 13:46

    You can revert the merge commit on master. When you later really want to merge the branch, you will have to revert the revert first. For a detailed explanation, see here:

    http://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt

    0 讨论(0)
  • 2020-12-15 14:03

    You can either:

    Revert your change

    git revert HEAD

    This will create a new commit that reverts the changes that you just pushed up to master. This is the safest option because other people may have already pulled down the change that you have pushed up.

    Change your commit history and force push the change

    You can remove the commit that you just pushed up with:

    git reset --hard HEAD~1

    git push origin master --force

    You don't want to do this unless you're absolutely sure that no one has pulled down your changes from master.

    For more info, see Delete commits from a branch in Git

    0 讨论(0)
提交回复
热议问题