1 / 16
Git submodules
Devops Meetup Krk20150617Maciej Lasyk
4 / 16
git submodule add <URL> <dirname>
git status
git diff --cached --submodule
5 / 16
.gitmodules
[submodule "ansible-piwik"] path = ansible-piwik
url = [email protected]:docent-net/ansible-piwik.git
6 / 16
Cloning repos w/submodules?
git clone <URL> # just standard content without submodules data
7 / 16
Cloning repos w/submodules?
git submodule initgit sumobule update
8 / 16
Cloning repos w/submodules?
git clone --recursive <URL>
9 / 16
Update submodule code to the latestrevision?
# run in submodule dirgit fetch
git merge <origin/master>
# updates all submodules data# run from maindir
git submodule update --remote
10 / 16
Change submodule branch?.gitmodules~/.git/config
11 / 16
by default: detach HEAD state
git checkout <branch>git submodule update --remote merge
12 / 16
Pushing changes?
git push --recurse-submodules
13 / 16
Removing submodule?
# edit .gitmodulesgit rm --cached <submodule-dir>
# commit change
14 / 16
foreach
git submodule foreach 'git diff'git submodule foreach 'git pull'
15 / 16
Thanks :)Maciej Lasyk
@docentnethttp://maciej.lasyk.info