Re: Commiting changes onto more than one branch
From: Thomas Rast <hidden>
Date: 2016-06-15 22:47:46
Mike Jarmy wrote:
Suppose that I checkout the v3 branch, and fix the bug by editing several different files. (Lets assume for now that the files in question have not diverged between any of the 3 branches, even though tons of other files have changed). How do I commit the bugfix into all of v3, v4 and v5? Clearly, merging the branches together would be bad. So I think what I should do is perform 3 different commits, but I'm not quite sure how to juggle the git index (or stash or whatever) to accomplish this. This may be a really obvious question, but I'm a confused git newbie.
You can build the fix on top of the merge-base of v3, v4 and v5, i.e.
git checkout -b myfix $(git merge-base v3 $(git merge-base v4 v5))
# work
git commit
and then merge it to each of the version branches:
for b in v3 v4 v5; do
git checkout $b
git merge myfix
done
So much for the theory. In the model suggested in the gitworkflows(7)
manpage and used in git.git, v3 is contained in v4 and similar for v5.
This means that after merging (possibly several) fixes to v3, you can
merge v3 into v4 and v4 into v5 (and so on, through all versions) to
propagate the fixes.
--
Thomas Rast
trast@{inf,student}.ethz.ch