Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I overwrite, not merge, one remote branch into another branch?

I have two branches. Staging and Beta. Staging has code in it ( including files ), that I do not want at all. How can I make Beta completely overwrite Staging, so that none of those files or code are merged from Staging into Beta.

I see some people recommend doing this :

git checkout staging git merge -s ours beta 

But I don't believe the pre-existing files would be a "code conflict" and therefore would not be removed. Am I wrong? If I'm right, how would I accomplish this?

like image 477
Trip Avatar asked Apr 23 '13 14:04

Trip


People also ask

How do I overwrite a branch in github?

Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.

How do I stop a branch from merging?

You can use the git reset --merge command. You can also use the git merge --abort command.

Does git merge overwrite?

Usually git does not overwrite anything during merge.

How do I force a branch to overwrite a master?

Force PushingUsing the -f flag, your previous master is completely overwritten with develop , including its history. Warning: this erases all commits from the master branch that are not also in the develop branch.


1 Answers

You can simple delete staging and re-create it based on beta:

git branch -D staging git checkout beta git branch staging 
like image 179
Daniel Hilgarth Avatar answered Sep 20 '22 19:09

Daniel Hilgarth