git submodules

15
1 Git submodules Devops Meetup Krk 20150617 Maciej Lasyk

Upload: maciej-lasyk

Post on 27-Jan-2017

3.603 views

Category:

Technology


0 download

TRANSCRIPT

1 / 16

Git submodules

Devops Meetup Krk2015­06­17Maciej Lasyk

GIT submodules ­ WTF?

2 / 16

3 / 16

PL: moduły zależne

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

@docent­nethttp://maciej.lasyk.info