I have a dozen feature branches that I would like to manually test at the same time by merging them into a single test branch, to avoid repeating the overhead of setting up the test environment for each feature branch. The branches have no merge conflicts because they don't touch the same parts of the code base.
While testing in this way, I might encounter a problem with one of the new features. I would like to be able to patch such a problem and continue testing. Then, when the testing is over, I would like to propagate those changes back to the relevant origin branches.
The impact of checking out the feature branch, patching it, then merging those changes back into the test branch, is significant enough that I hope to eliminate it from my workflow. Among other costs, it requires my IDE's language server to re-process the whole code base (~450k lines of C++) which means I lose those features for a significant amount of time each time I do this.
Does git have any commands, or are there any additional tools, that would enable this sort of workflow?
There is no easy to use feature in Git that would permit the proposed workflow. Since it was also a pain-point for me, I have implemented the command git post
, the opposite of git cherry-pick
.
You find its implementation in my Github repository. You can just extract the file git-post.sh
(raw version) and place it such that PATH lookup finds it under the name git-post
. Don't forget to make the file executable.
You use it like this (documentation):
git merge feature
# test, test, test; oops, here's a bug
# fix bug
git add -u
git commit # provide message
git post feature
In this case, the top-most commit is replicated on top of branch feature
and advances the branch to the replicated commit.
If you make multiple commits that belong to different topic branches feature-A
, feature-B
and feature-C
(in this order) you can do
git post feature-A HEAD~2
git post feature-B HEAD~1
git post feature-C
This implementation of git-post
requires that the replication on the feature branch is possible without merge conflicts.