git submodule

git submodule

build-linux.sh
#!/bin/sh

set -x
git pull
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
git submodule init
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
git submodule update
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
make OYW_HASQT=1 OYW_CCC=1 clean
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
make OYW_HASQT=1 OYW_CCC=1
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
echo "Done"
  • Below are examples

add submodule

...
$ git submodule add https://github.com/iamyuiwong/cppnetwork.git modules/cppnetwork
...

$ cat .gitmodules
[submodule "modules/base64ende"]
    path = modules/base64ende
    url = https://github.com/iamyuiwong/base64ende.git
[submodule "modules/checksum"]
    path = modules/checksum
    url = https://github.com/iamyuiwong/checksum.git
[submodule "modules/cppnetwork"]
    path = modules/cppnetwork
    url = https://github.com/iamyuiwong/cppnetwork.git

add submodule url (from .gitmodules) to .git/config 以及后续 submodules clone

Set url(s):
git submodule init
Clone:
git submodule update

brand-new clone master and sub modules:

git clone --recursive https://github.com/iamyuiwong/liboywcppbase.git

watch

git submodule
Or.
git submodule status
Or.
git submodule status --recursive

E.x.
 38837fa4806b58bc17a002c5a1db36b95b1be7e5 modules/base64ende (heads/master)
 fdbf9709c66cb027e44b92cf12b9f3f5e893083e modules/checksum (heads/master)
 cc1977851ebbf2c72d60d88d49161be43e5f3796 modules/cppnetwork (heads/master)

get remote latest need by master

E.x.
git submodule update --remote

Or.
git submodule update --remote modules/cppnetwork

foreach

E.x.
git submodule foreach 'git checkout master'

git submodule foreach 'git pull'

update master deps.

  • 1 git submodule foreach 'git pull'
  • 2 add and commit