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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.