Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
1 view
in DevOps and Agile by (29.3k points)

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.

1 Answer

+1 vote
by (50.2k points)

Try:

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.

To learn about more commands, you can visit the Git commands.

Browse Categories

...