Just as an alternative to the SO question "How do you merge selective files with git-merge?", I just found this GitHub thread which could be more adapted for merging a whole subdirectory, based on git read-tree:
My repository => cookbooks
My repository target directory => cookbooks/cassandra
Remote repository => infochimps
Remote repository source I want merged into cookbooks/cassandra => infochimps/cookbooks/cassandra
Here are the commands I used to merge them
- Add the repository and fetch it
git remote add -f infochimps git://github.com/infochimps/cluster_chef.git
git merge -s ours --no-commit infochimps/master
- Merge only
infochimps/cookbooks/cassandra into cassandra
git read-tree --prefix=cassandra/ -u infochimps/master:cookbooks/cassandra
git commit -m 'merging in infochimps cassandra'
Addendum
It's bizarre,[edit me] — but the read-tree step can possibly fail like this:
error: Entry 'infochimps/cookbooks/cassandra/README' overlaps with 'cookbooks/cassandra/README'. Cannot bind.
... even when both files are identical. This might help:
git rm -r cassandra
git read-tree --prefix=cassandra/ -u infochimps/master:cookbooks/cassandra
But off course, verify manually that this does what you want.