Merging remote branches in git
-
17-02-2021 - |
Question
I am developing a system where I'm following the trails of another project, adding my own stuff but not directly to the original project. I setup my repository with three remote branches:
- Master - Where my development takes place.
- Vendor - Where I sync with the original project periodically.
- Integration - Where I want to merge (Master) and (Vendor) together.
My workflow idea is for the synchronization to take place automatically (since it's basically a fast-forward of sorts), and the integration to be half-manual (since it requires merges and fixes). I've got the first part (the sync) covered, but I can't figure out what command/s to actually issue to integrate Master and Vendor into integration.
This is the output of git branch -a:
* integration
master
vendor
remotes/origin/HEAD -> origin/master
remotes/origin/integration
remotes/origin/master
remotes/origin/vendor
How do I go forward from this point to:
- Synchronize this workspace with the remote repository?
- Merge vendor & master into integration?
- Push integration back to the remote repository?
And obviously, if I have something wrong in the workflow I'd love to hear it.
Solution
While the integration
branch is not strictly necessary (you could integrate directly vendor
into master
, by rebasing master
on top of vendor
), it can be useful.
Integrating a branch A
in a branch B
can be done by:
- merging
A
inB
(but that means any current development you have inB
is "on hold" pending the resolutions of any merge conflict, and the re-runs of all the tests) - rebasing
B
on top ofA
(git rebase A
), but that would changeB
's history.
I would rebase integration
on top of Vendor
, solving any conflict there, and then merge integration
in master
, keeping master
history linear.