Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping Git branches up to date while waiting for them to be merged into upstream

Tags:

git

branch

github

I forked a GitHub project, implemented a few features and fixed a few bugs in separate branches, sending pull requests for all of them.

While waiting for them to be accepted into upstream, I want to use all these features and fixes. For that, I create a branch 'my-master', from 'upstream/master' and merge all changes from other branches which are not yet in upstream. I also write a list of applied patches into the README.md.

When one of my patches goes to upstream, there is no reason to keep that branch any more, so I delete it.

It works, BUT, here there is a problem with such approach:

From time to time, I need to rebase all my unaccepted branches, to keep them up to date. After that, I have to recreate 'my-master' branch and update its README.md again.

Is there a way I can speed up or automate this?

Please, don't advise me to try git-up. It is useful, but does a different thing.

like image 837
Alexander Artemenko Avatar asked Oct 18 '13 17:10

Alexander Artemenko


1 Answers

One technique is to rebase your branch onto the upstream each time there is a release. You may want to create a tag at the old branch tip, or a dated-versioned branch name so that you don't lose your old history after garbage collection.

Or you may want to use the merging rebase script that msysgit uses https://github.com/msysgit/msysgit/blob/master/share/msysGit/merging-rebase.sh, which creates the impression of a continuous line of development (via the second parent) that is equivalent to the above rebasing processes.

In both cases you retain a set of commits that you were happy with should your rebase fixes (from conflicts) end up being problematic.

This covers two problems:

  1. upstream is slow to update (relative to the speed you want/need)
  2. upstream is targeted at a different 'platform' and you'll always need fixes 'on top' for your platform/purpose.
like image 161
Philip Oakley Avatar answered Nov 15 '22 04:11

Philip Oakley