Git Subtree Installation and Usage on Linux

Follow Apr 17, 2015 · 1 min read

Installing Git Subtree From Sources

Git subtree is a git helper to combine and manage multiple repos in one project.

This article describes how to install git subtree on Ubuntu 12.04 OS.

Since subtree is mostly collection of shell scripts and was introduced in moved to contrib package as part git version 1.7.9.11.The latest version of git available from standard sources on Ubuntu 12.04 is 1.7.9.5.Hence we will build and install the latest version of git from sources

Dependencies

Prior to installing git we need to install some dependencies


sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential


Compile Git Modules

Get the git sources from enter link description here


make prefix=/usr/ all

Install Git

For a global install it using /usr and /usr/local prefixes


sudo make prefix=/usr/ install

Compile and Install git contrib

  • Go into the git/contrib/subtree directory
  • Build and install git subtree

make
sudo make prefix=/usr install

Configure a subtree

We have created a repository called root we will configure the git respository adroid as subtree in root repository


git remote add adroid git@github.com:pyVision/adroid.git
git subtree add --prefix=adroid/ adroid master

  • First the repository of sub-directory is added as remote of the present repository

  • The git subtree add command tells git to add that repo’s code into a path in the parent’s project, specified by prefix in this case adroid .The last prefix master is the branch you are pulling code from.

A complete reference for git subtree management can be found at enter link description here

Written by