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
featurebranchcommits 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 masterwill generate a patch file for each commit onfeaturebranchthat's not onmaster. You can then switch tomasterand apply the patches withgit am.(In the more straightforward case where
featurebranchhasn't been shared with anyone, then rather than rebasingmasteragainstfeaturebranch, you can instead rebasefeaturebranchagainstmaster, which will makefeaturebrancha copy ofmasterwith extra commits on top, and then rebasemasteragainstfeaturebranch, which will make git fast-forwardmaster.)