git command for making one branch like another

前端 未结 9 1323
半阙折子戏
半阙折子戏 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条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 11:46

    change to the remote upstream branch and do a git merge with the merge strategy set to ours.

    git checkout origin/master
    git merge dev --strategy=ours
    git commit ...
    git push
    

    All the history will still be present, but you'll have an extra merge commit. The important thing here is to start from the version you want to be at and merge ours with the branch github is actually at.

提交回复
热议问题