GitHub Submodule Setup and Linking

Idea:

Think of a submodule as a github repo inside another github repo. (Mind blown?) The submodule may be maintained independently of the main repo, while its contents remain reliably accessible to the main repo.

Our usage:

Ok, but what about more instructions -- with examples -- you say? Read on for a team-based walk-through:


1. Know your team name.

2. Create & clone your team repo. (PROTIP: create your repo on github.com first.)

$ git clone [TEAM_REPO_CLONE_URL]

Exempli gratia,

$ git clone git@github.com:tofr/semper-ubi-sub-ubi.git

Cloning into 'semper-ubi-sub-ubi'...

remote: Counting objects: 4, done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0

Receiving objects: 100% (4/4), done.

Checking connectivity... done.

3. Clone the main repo.

$ git clone [MAIN_REPO_CLONE_URL]

Exempli gratia,

$ git clone git@github.com:ap251/lab00.git

Cloning into 'lab00'...

remote: Counting objects: 4, done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0

Receiving objects: 100% (4/4), done.

Checking connectivity... done.

4. Change into the correct directory and add your repo as a submodule.

$ cd [LOCAL_DIR_FOR_MAIN_REPO]/[YOUR_PD]

$ git submodule add [TEAM_REPO_HTTPS_CLONE_URL] [SUBMODULE_LINK_NAME]

Note: Unless otherwise specified, SUBMODULE_LINK_NAME should follow this format:

teamName_LaastF_LbastF_LcastF'...

Exempli gratia,

$ cd lab00/1/

$ git submodule add https://github.com/tofr/semper-ubi-sub-ubi.git nerdPower_GladwellM_NyeB_RandallL

Cloning into '3/nerdPower_GladwellM_NyeB_RandallL'...

remote: Counting objects: 4, done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0

Unpacking objects: 100% (4/4), done.

Checking connectivity... done.

5. Commit and push changes

$ git pull

$ git commit -am "added submodule for [TEAM_NAME]"

$ git push

Exempli gratia,

$ git commit -am 'added submodule for nerdPower'

[master 2c07a22] added submodule for nerdPower

 2 files changed, 4 insertions(+)

 create mode 100644 .gitmodules

 create mode 160000 3/nerdPower_Gladwell-M_Nye-B_Randall-L

PROTIP: You do not have to pull first,

 but it is a good idea,

 as another thinker/team may have pushed since you began this procedure...

6. Remove the main repo and go about your business

$ cd [path/to/dir_containing_main_repo]

$ rm -rf [LOCAL_DIR_FOR_MAIN_REPO]

Exempli gratia,

$ cd ../../

$ rm -rf lab00/