how to reset develop branch to master

前端 未结 3 1551
陌清茗
陌清茗 2021-01-30 12:27

I have develop & master branches, my develop branch is messy now and i would like to reset it and make it as a copy of my master

相关标签:
3条回答
  • 2021-01-30 13:08

    If you want to make develop be identical to master, the simplest way is just to recreate the pointer:

    git branch -f develop master
    

    Or, if you already have develop checked out:

    git reset --hard develop master
    

    Note however that both of these options will get rid of any history that develop had which wasn't in master. If that isn't okay, you could preserve it by instead creating a commit that mirrored master's latest state:

    git checkout develop
    git merge --no-commit master
    git checkout --theirs master .
    git commit
    
    0 讨论(0)
  • 2021-01-30 13:19

    I'm a bit late to the party, however, after merging my dev branch into the master and pushing to the server, I do the following:

    git fetch

    git checkout development

    git merge origin/master

    git push

    The the dev branch is one commit ahead of the master branch, and other developers don't have to worry about all commits in the development branch being reset.

    0 讨论(0)
  • 2021-01-30 13:25

    if you just want them to be the same thing

    then

    //from Develop and assuming your master is up to date with origin/master
    git reset --hard master
    
    0 讨论(0)
提交回复
热议问题