I've got a project (GitHub-based) with a branch structure like so
master: A - B - C - D
\
release: W - X - M
/
bugfix: Y - Z
Thus once bugfix
is merged, release
will have A - W - X - Y - Z - M
, where M is the merge commit and Y
& Z
are the original commits from the bugfix
branch. All pretty normal so far.
Now, what I want to do is get M
along with Y
and Z
into master
. But here's the caveat - I do not want W
or X
in master. Why? W
and X
are commits like "Bump to our hotfix release version" that have no place in master
. So in the end, I want master
to be A - B - C - D - Y - Z - M
.
If I git cherry-pick
on M
, I just get M
and I lose the history of Y
and Z
. This is what I was doing, but then I lose functionality in git blame
in the future, and authors end up getting hidden (since GitHub commits a merge as authored by the person who merged it, not the original submitter).
If I git merge
on M
, I get the entire branch including W
and X
that I don't want.
How can this be accomplished?
Let me clarify the X to my Y a bit more:
Our project is entirely GitHub based using a fork-and-PR model (as is normal there).
What's before A doesn't matter; our release branch is based on A and then we added W and X to it to make our release (the tag is on X).
So Random Contributor Alice makes a bugfix coming from and targeting our Release branch.
release: W - X
\
bugfix: Y - Z
Our team member Bob merges that pull request into our Release branch.
release: W - X - - - M
\ /
bugfix: Y - Z
And importantly, I, or anyone on the project, can't touch bugfix
once it's merged. It's on Alice's fork of the project, and we have this in our Release branch:
A - W - X - Y - Z - M
And since we made our Release branch, new commits (B
, C
, D
) have been added to our Master branch.
Now, and this is the crux of my question: I want to get the entire history of that Pull Request - the original commits from Alice (Y
and Z
) and the merge details from Bob (via merge commit M
) - into our master
branch.
I was quite happy to just cherry-pick the merge, but because of the idosyncracies of how GitHub handles PR merges, that means that all trace of Alice (and her commits) are lost if I do so. This is what we want to avoid.