Git merge with force overwrite

前端 未结 6 664
悲哀的现实
悲哀的现实 2021-01-29 19:03

I have a branch called demo which I need to merge with master branch. I can get the desired result with following commands:

git pull or         


        
6条回答
  •  迷失自我
    2021-01-29 19:34

    This merge approach will add one commit on top of master which pastes in whatever is in feature, without complaining about conflicts or other crap.

    Before you touch anything

    git stash
    git status # if anything shows up here, move it to your desktop
    

    Now prepare master

    git checkout master
    git pull # if there is a problem in this step, it is outside the scope of this answer
    

    Get feature all dressed up

    git checkout feature
    git merge --strategy=ours master
    

    Go for the kill

    git checkout master
    git merge --no-ff feature
    

提交回复
热议问题