Git Overwrite master with branch

前端 未结 2 1419
忘掉有多难
忘掉有多难 2021-01-30 13:40

I want to overrite master with a particular branch after making changes to it, what I done to do it is:

Step 1: Checkout brranch from Git, using command :



        
相关标签:
2条回答
  • 2021-01-30 13:55

    git branch -f master dev_branch will rewrite local master branch.

    git push remote +dev_branch:master will rewrite remote branch.

    • NOTE: If the above doesn't work, the name remote could be origin for you (i.e. git push origin +dev_branch:master)
    0 讨论(0)
  • 2021-01-30 13:55

    To completely replace the master branch with the contents of any other feature_branch you can also use:

    git checkout feature_branch
    git merge -s ours --no-commit master
    git commit      # Add a message regarding the replacement that you just did
    git checkout master
    git merge feature_branch
    

    See: http://git.tutorialhorizon.com/2014/10/05/replace-the-master-branch-with-another-branch-in-git/

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