where dev/master was in the middle, getting merged into continuously be various teams and their feature branches. Periodically a release branch is created and devs are stuck with the dilemma of having to merge a feature branch into both dev and release.
A release1 / D---E---F---G development \ H---I---J feature_for_release1
So, as a proof of concept what I have done is show how feature_for_release1 could be attached onto release1 without including F.
I first created a staging branch off release1:
MINGW64 /c/Work/testing/my_try_git (release1) $ git checkout -b stage-release1-feature Switched to a new branch 'stage-release1-feature'
Then merged in feature-for-release1:
git merge feature-for-release1
At this point I printed the log and did a rebase interactive:
MINGW64 /c/Work/testing/my_try_git (stage-release1-feature) $ git log --pretty=oneline --graph * 14b50fed8999aa785e7333a239b532c3f1fe11e0 file added for release1 * b6a8a66b8bd64de49b666d0e627e68de76747ac4 files changed for release1 * e3ee2edbbfbb2ef629170309d5e35cad6181f4d6 Merge pull request #1 from awgtek/feature-for-release2 |\ | * cd091e9f75d8580c34c9a73c0f30aef616816a7f adding changes for release 2 |/ * eb95ed7111130064272be69957644223212d9981 Remove 322 * fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak * 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2 * 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober * 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files * 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story MINGW64 /c/Work/testing/my_try_git (stage-release1-feature) $ git rebase -i eb95ed7111130064272be69957644223212d9981In the editor was shown:
As can be seen, I am rebasing to eb95ed which corresponds to point E on the above diagram. I am also dropping cd091e9 from the replaying of this sequence of commits (top to bottom) onto the staging branch which is being rebased to the point just before eb95ed.
When I saved the file, it got an error:
error: could not apply b6a8a66... files changed for release1 When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort". Could not apply b6a8a66b8bd64de49b666d0e627e68de76747ac4... files changed for release1
This was because one of the files committed in the dropped commit was also changed in a subsequent kept commit. So I had to edit the offending file remove all the merge conflicts, do a git add, and a git rebase --continue. After which the rebase was completed.
MINGW64 /c/Work/testing/my_try_git (stage-release1-feature) $ git log --pretty=oneline --graph * 752d1871b4e8632a1daf8fe7579884f08dfa0b17 file added for release1 * faa4e3ba142bc00015bdba7c2988e02319cbfaab files changed for release1 * eb95ed7111130064272be69957644223212d9981 Remove 322 * fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak * 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2 * 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober * 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files * 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story
I could then push stage-release1-feature to github and merge it into release. see here.