Tay Ray Chuan home archive

subtree merge

Fri, 23 Sep 2011 23:57:09 +0800 | Filed under unix, gsoc 2011 git diff, recipe

I was compiling my gsoc code submission the other day. It was done as a git repo (available here), mostly collections of patches, but I also had some gists lying around. Their individual revisions were probably not that interesting, but just adding them as history-less blobs would was also undesirable.

So I decided to do a subtree merge on them. I found a good walk-through on Help.Github. Below is the script I used to merge in all of my gsoc gists. What's interesting was that I wasn't creating a branch for each gist that I pulled/fetched - I just used the temporary FETCH_HEAD ref to hold the gist's history.

gist=$1

git fetch git://gist.github.com/$gist.git \
	&& git merge -s ours --no-commit FETCH_HEAD \
	&& git read-tree --prefix=gists/gist-$gist -u FETCH_HEAD \
	&& git commit -m "subtree merged in gist $gist"
blog comments powered by Disqus