Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging remote branches in git

Tags:

git

git-remote

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:

  1. Master - Where my development takes place.
  2. Vendor - Where I sync with the original project periodically.
  3. 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:

  1. Synchronize this workspace with the remote repository?
  2. Merge vendor & master into integration?
  3. Push integration back to the remote repository?

And obviously, if I have something wrong in the workflow I'd love to hear it.

like image 889
Eldad Mor Avatar asked Nov 04 '22 12:11

Eldad Mor


1 Answers

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 in B (but that means any current development you have in B is "on hold" pending the resolutions of any merge conflict, and the re-runs of all the tests)
  • rebasing B on top of A (git rebase A), but that would change B's history.

I would rebase integration on top of Vendor, solving any conflict there, and then merge integration in master, keeping master history linear.

like image 147
VonC Avatar answered Nov 09 '22 12:11

VonC