How to remove merge results in git

This question already has an answer here:

  • Reset local repository branch to be just like remote repository HEAD 18 answers

  • To set branch preprod equal to that in origin/preprod , simply do:

    git checkout preprod
    git reset --hard origin/preprod
    

    NB: This will cause you to lose the 68 commits that you currently have between the two.


    Your local branch is ahead of origin/preprod, so there are two different directions depending on what you mean by "exactly the same code" as the remote branch. Your in a state where you are ahead of the remote branch (which is visible in git status by the ahead by X commits message). You have two main pathways (and a ton of sub-options I won't explore):

  • Update remote to catch up to your local branch

    git push origin preprod

  • Reset your local branch to revert back to your remote branch

    git reset --hard HEAD~68

  • Where 68 is the number of commits you're ahead of your remote branch. NOTE: this will delete these commits! Add them to another branch with git checkout -b backup or run git stash if you want to save them to the side for now.

    Either way, you'll be aligned with upstream at this point.

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

    上一篇: 如何重置Git仓库到HEAD?

    下一篇: 如何在git中删除合并结果