]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-subup
Merge branch 'master' into epic
[dotfiles.git] / bin / git-subup
1 #!/bin/bash
2 # Checkout and update source for all registered submodules (.gitmodules).
3 # Optionally 'git pull' on each submodule to check for updates.
4
5 # Change to root directory
6 cd $(git rev-parse --show-toplevel)
7
8 # Ensure all submodules (and child submodules) are checked-out
9 git submodule update --init --checkout --recursive
10
11 # Update submodules' remotes based on .gitmodules
12 git submodule sync
13
14 # Forcibly update each submodule's "master" branch to be the current revision
15 # in case HEAD is detached (e.g. due to "git submodule update --checkout")
16 git submodule foreach --recursive 'git checkout --quiet -B master'
17
18 if [ "$1" = "pull" ]; then
19 # Fetch & pull any new updates from submodule's origin (but *NOT* any child
20 # submodule updates -- those should come from the submodule proper)
21 git submodule foreach 'git-up origin'
22 fi