]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-subup
bin/git-subup: Better compatibility with older Git versions
[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 --recursive
10
11 # Update submodules' remotes based on .gitmodules
12 git submodule sync
13
14 if [ "$1" = "pull" ]; then
15 # Fetch & pull any new updates from submodule's origin (but *NOT* any child
16 # submodule updates -- those should come from the submodule proper)
17 git submodule foreach 'git-up origin'
18 fi