Git sub-tree merging back to the subtree for pushing to an upstream
While git sub-tree merge strategy works great for merging a library into vendor (when you want to pull HEAD on that library instead of waiting for releases), I had trouble finding documentation on pushing back to upstream. This is annoying because one of the most obvious times you may want to use subtree is when you manage the library yourself, so can just pull straight from the repo, and want to push your maintenance changes back.
Surprisingly, and not what I have come to expect from git, it just works. From the example in the docs I linked, when you are checked out on master
git merge --squash -s subtree --no-commit rack_branch
will merge the rack_branch into where you have specified. But it just works the other way to. If checked out on rack_branch
git merge --squash -s subtree --no-commit master
will do what you expect, so you can now just push your library branch back to it’s upstream.
Awesome!
