How to do it...

  1. We'll add the subproject as a new remote and fetch the history:
$ git remote add lib_a
$ git fetch lib_a 
warning: no common commits 
remote: Reusing existing pack: 18, done. 
remote: Total 18 (delta 0), reused 0 (delta 0) 
Unpacking objects: 100% (18/18), done. 
 * [new branch]      develop    -> lib_a/develop 
 * [new branch]      master     -> lib_a/master 
 * [new branch]      stable     -> lib_a/stable 
  1. We can now create a local branch, lib_a_master, which points to the same commit as the master branch in lib a (lib_a/master):
$ git checkout -b lib_a_master lib_a/master ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.