Git merge with force overwrite -git force merge
I have a branch called demo which I need to merge with the master branch. I can get the desired result with the following commands:
git pull origin demo
git checkout master
git pull origin master
git merge demo
git push origin master
My only concern is, if there are any merge issues, I want to tell git to overwrite changes in a master branch without giving me a merge prompt. So basically changes in the demo branch should automatically overwrite changes in the master branch.
I looked around there are multiple options but I don't want to take chances with merging.
For force merge git you can try these commands:
git fetch origin # update all our origin/* remote-tracking branches
git checkout demo
git merge -s ours branch
git checkout master
git merge -s ours origin/master
git merge -s ours branch
git push origin master
These commands will help to overwrite the demo branch.