git command for making one branch like another

前端 未结 9 1355
半阙折子戏
半阙折子戏 2020-11-22 11:36

I\'m trying to take a branch with changes and bring it back to be identical to the upstream it diverged from. The changes are both local and have been pushed to github, so n

9条回答
  •  广开言路
    2020-11-22 11:53

    It sounds to me like you just need to do:

    $ git reset --hard origin/master
    

    If there is no change to push upstream, and you simply want the upstream branch to be your current branch, this will do that. It is not harmful to do this locally but you will lose any local changes** that haven't been pushed to master.

    ** Actually the changes are still around if you have committed them locally, as the commits will still be in your git reflog, usually for at least 30 days.

提交回复
热议问题