Skip to content

Instantly share code, notes, and snippets.

@kbarber
Created December 11, 2011 20:28
Show Gist options
  • Save kbarber/1462570 to your computer and use it in GitHub Desktop.
Save kbarber/1462570 to your computer and use it in GitHub Desktop.
Git subtree experiment
Two projects:
a
subproject
Enter the 'a' directory and add a remote:
% cd a
% git remote add subproject ../subproject
% git remote -v
subproject ../subproject (fetch)
subproject ../subproject (push)
%
Fetch the subproject project and create a branch for it:
% git fetch subproject
% git branch -r
subproject/master
% git checkout -b subproject subproject/master
Switch back to master and merge in subproject:
% git read-tree --prefix=subproject/ -u subproject
Then commit the changes in:
% git commit -a
To pull in new commits:
% git checkout subproject
% git pull
% git checkout master
% git merge --squash -s subtree --no-commit subproject
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested
Then commit:
% git commit -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment