0

I have two branches Staging and Master. All the feature branches get merged into Staging. When I want to merge Staging with Master (What I mean is I want to push Staging to Master and override all the conflicts).

I tried

git checkout master
git merge staging

This is where I have all the conflicts and I want override Master with Staging. I have read about

git checkout --theirs .
git add .

But not sure if I need to use theirs or ours.

Could you guide me on how to override Master with Staging. resolve all conflicts just replace Master with Staging.

If I am doing anything wrong here do correct me.

Thanks R

Shubham Khatri
  • 211,155
  • 45
  • 305
  • 318
BRDroid
  • 2,522
  • 4
  • 32
  • 81
  • Hello, you can have a look at this answer: https://stackoverflow.com/a/25576672/5073674 So what you want to do is git checkout master git merge staging git checkours --theirs . (to pick all from staging) git add . – mrtna Feb 02 '18 at 15:56
  • That procedure is a great way to not get the result OP specified they want. Too bad this is marked dup or I could provide an answer that actually addresses the question. (And no, I can't just add the answer to the other question, because it's not the same question - i.e. this is NOT a dup of that question.) – Mark Adelsberger Feb 02 '18 at 16:12
  • @MarkAdelsberger: oops, I'll de-duplicate (I was trying to go fast this morning...) – torek Feb 02 '18 at 21:26

2 Answers2

0
git checkout master
git merge -s theirs staging

This accepts all changes from the other branch, in this case staging.

git checkout master
git merge -s ours staging

This accepts all changes from the current branch, in this case master.

Code-Apprentice
  • 69,701
  • 17
  • 115
  • 226
  • [There is no `-s theirs`, though some people think there should be](https://stackoverflow.com/q/173919/1256452). – torek Feb 03 '18 at 01:20
0

If you want master to point to staging

Go to branch master

git checkout master

then force master to point to stagin

git reset --hard staging

that's all, but you will loose everything that is not into master Merge and resolve fixes is the best option

Ôrel
  • 4,349
  • 2
  • 19
  • 34