Reputation: 3333
I'm working on a project with a particular git project repository. There are three branches:
master
development
release
The structure is as follows: from master
spawns development
, where features are developed and tested. Once a set of features has been developed, development
is merged (no fast-forward) into master
, and that merge commit represents either a release version or an intermediate version. Nothing gets directly committed to master
, it only consists of merge commits from development
.
When a version is considered a release version, it needs to be moved somehow to release
. The idea is that release
has a linear history in which each commit represents a release version. There should be no trace of any intermediate commits in release
.
Take this example: release/01.03.00.00
represents the same repository state as master/01.03.00.00
. I now want to create a single commit in release
which represents the difference between master/01.04.00.00
and master/01.03.00.00
. Can it be done without using git patch
? Using git cherry-pick
with a range of commits (take into account that sometimes there can be several merge commits in master
between release versions) did not seem to work (it required -m
in order to deal with merge commits but would then complain about not-merge commits).
Upvotes: 4
Views: 251
Reputation: 365
I don't have a repo to test this but, have you tried creating a branch from master, squash all commits of that new branch, and then merge that into release?
Something like:
$ git checkout master
$ git branch -b tmp-master
$ git rebase -i HASH # the hash of the first commit from master you want to bring into release
# pick the last commit, squash all other commits
$ git checkout release
$ git cherry-pick HASH # put the hash of the commit you just made in tmp-master
Upvotes: 1