How to do it...

  1. We'll add the subproject as a new remote and fetch the history:
$ git remote add lib_a https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_lib_a.git
$ 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. 
From https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_lib_a.git 
 * [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 O’Reilly online learning.

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