On an existing repo:
git submodule add <remote repository> <local path>
This should return something similar to:
git submodule add [email protected]:demagu/ansible.git .ansible
Cloning into '/Users/user/Sites/raceroster.com/pursuit/.ansible'...
remote: Counting objects: 3773, done.
remote: Compressing objects: 100% (221/221), done.
remote: Total 3773 (delta 105), reused 0 (delta 0), pack-reused 3511
Receiving objects: 100% (3773/3773), 646.35 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1526/1526), done.
Checking connectivity... done.
.gitmodules
file should have been created with content similar to the one below:
[submodule ".ansible"]
path = .ansible
url = [email protected]:demagu/ansible.git
Initialize submodule:
git submodule init
Confirm status:
git submodule status
Should return something similar to:
1f5124a7c63c4d625c0e232251f4e503d0dea9ec .ansible (heads/master)
To switch your submodule to a different branch open your .gitmodules
for editing (ie. nano .gitmodules
) and add branch = your-branch
below url
so your file looks similar to this:
[submodule ".ansible"]
path = .ansible
url = [email protected]:demagu/ansible.git
branch = pursuit-local-env
Save and exit.
Then:
git submodule update --remote
which should result in:
Submodule path '.ansible': checked out '42f8ab3e68758ea2731942dbacfd7ee7dde3e281'