Reputation: 555
Currently I have a scenario where I want to locally merge two branches to a third branch. So the scenario is. FYI I am a noob in github.
Now I want to merge Epic_1 branch first to Master and then merge Epic_2 branch to master on top of merged Epic_1 and Master. I am not sure what to search for to get proper answer so adding this question. IMPORTANT - I want all of this to be done locally only and nothing should go to remote branch.
Thanks, Ray
Upvotes: 0
Views: 690
Reputation: 96464
You just
git fetch # in case these branches are from the remote and to be up-to-date
git checkout master
git merge branch_1
git merge branch_2
You can now do
git status
and
git log
to see the state of master. It will be local unless/until you explicitly push master to the remote (probably origin
in your case).
If there are merge commits you'll need to resolve them but you'll get an appropriate message indicating that and that would be a separate question from this.
There are also lots of options with merges and rebasing and relevant topics like fast-forwarding but that is beyond the scope of this question.
Upvotes: 0
Reputation: 387557
git checkout master # go to master since that’s your target branch
git merge Epic_1 # merge in the first branch
git merge Epic_2 # merge in the second branch
This will give you a result that looks approximately like this:
(old) master master (after merges)
↓ ↓
* -- * -- * -- * -- * -- M1 -- M2
/ /
* -- * -- * -- * -- * - /
↑ /
Epic_1 /
/
* -- * -- * -- * -- * -- *
↑
Epic_2
As with everything in Git, this happens only locally, so nothing on any of your remotes is affected. Of course, you can then push the master branch to update it on your remote.
Upvotes: 3