At work we develop on top of a feature branch model where all integrations end up in the master
branch eventually. We branch from master
and merge to master
. This results in a very complex history graph and we are looking at ways to simplify our development workflow.
One way of doing so it to rebase instead of merge. However, we have an internal GitLab instance installed where overwrite permissions are disabled (and they are not going to be enabled for our project only). As such rebase is out of the question.
I honestly don't see any way around this. But I'm no Git expert and I might be missing something.
Any suggestions?
EDIT - my first answer was by no means the best way, although it would work. I've left it below in case it interests anyone. A better answer is the following:
You can use git cherry-pick with a range of commits to apply the
featurebranch
commits one at a time tomaster
. Any commit range spec will do, but in your case the easiest is probably (with master checked out):which means 'cherry-pick everything on featurebranch that isn't on master'.
Old, poor solution
You could use git format-patch and git am.
While on branch
featurebranch
, runninggit format-patch master
will generate a patch file for each commit onfeaturebranch
that's not onmaster
. You can then switch tomaster
and apply the patches withgit am
.(In the more straightforward case where
featurebranch
hasn't been shared with anyone, then rather than rebasingmaster
againstfeaturebranch
, you can instead rebasefeaturebranch
againstmaster
, which will makefeaturebranch
a copy ofmaster
with extra commits on top, and then rebasemaster
againstfeaturebranch
, which will make git fast-forwardmaster
.)