I have two rooms in which I maintain some source code using git, a "dev" room where most development happens and a "deploy" room in which we actually use the software. Inevitably some changes happen in the deploy room as well. I'd like both rooms to share the same history in git.
Not updating refs/heads/master (new tip <hash> does not contain <master's hash>)
I never found the perfect solution, but what we do now seems to work. The main drawback is that commits within the deployment room initially have one SHA1 that then changes to a different SHA1 after being merged with the dev room. The good news is that
git quite easily recognizes them as the same commits can can
merge right through them.
dev/masterwhich has the newest development in the dev room.
deploy/masterwhich has the newest development in the deploy room.
dev_deploy_commonwhich is the last commit the two histories share.
When we move code from dev to deploy (using a bundle), we bring the commits in as part of the
dev_deploy_common branch within the deploy room (
git pull into
dev_deploy_common), and then from
deploy/master do a
git merge dev_deploy_common and resolve and conflicts then and there.
When we move code from deploy to dev (which must be a text file) we make a few extra steps:
First we rebase
dev_deploy_common so that all of our patches are contiguous. This is generally easy since we've already handled any conflicts during the merges which occurred when bringing the bundle from dev to deploy.
Second we generate a patch set using
git format-patch -M25 -C25 --find-copies-harder -k --ignore-if-in-upstream
-M25 -C25 --find-copies-harder options just reduce the output text size. The
-k option keeps commit subjects intact. The
--ignore-if-in-upstream restricts our commits to just the new ones since
The result of this is a
patchset.txt collection of patches. This file can be hand-reviewed and then moved to the dev room.
In the dev room we import the patchset using the following command:
git am -k -3 --keep-cr --committer-date-is-author-date patchset.txt
Unfortunately, even though we use all the commands we can to keep the patch exactly the same, a few of the attributes change, primarily the committer. As a result the "same" commit will have different SHA1's in the dev and deploy rooms. This difference will persist until we move a bundle back into the deploy room.
When moving a bundle from dev to deploy, the
merge operation (typically) recognizes the identical patches and seamlessly replaces the commit with the one in the dev history. See Step 1.