Skip to content
Laurent Gatto edited this page Feb 2, 2016 · 6 revisions

Repository aggregation using git-subtree

Add a repository to TM

To add the master branch from the lgatto's new-material github repository:

git subtree add -P _new-material [email protected]:lgatto/new-material.git master

Pull latest changes from new-repository

New changes pushed to new-material are not automatically propagated to TeachingMaterial. This has to be performed manually from TM:

git subtree pull -P _new-material https://github.com/lgatto/new-material.git master

To update all the subtrees in TeachingMaterial, one can use

  for i in $( ls -d  _* ); 
  do 
      g=`echo $i | sed -e 's/_/https:\/\/github.com\/lgatto\//' -`; 
      g=$g.git; 
      git subtree pull -P $i $g master ; 
  done

Any pulled modifications must be explicitly pushed to master.

Installation

git-subtree is available in git version 1.8.3 (possibly 1.8.2, not 1.8.1). To install git-subtree, download the latest git source code and proceed as described in the INSTALL file.

Reference

See the https://github.com/git/git/blob/master/contrib/subtree/ repo for details and in particular the git-subtree.txt file.

Another useful reference: Working with submodules.