iimuz
9/26/2018 - 11:22 PM

template command for git submodule

template command for git submodule

# add submodule
git submodule add https://hoge.git hoge_directory

# remove submodule
git submodule deinit -f hoge_directory
git rm -f hoge_directory

# clone
git clone hoge_repository --recurse
# or only update submodule
git submodule update --init --recursive

# for windows crlf
git submodule foreach "git config --local core.autocrlf true; git ls-files | xargs rm; git clean -xdf && git reset --hard;"

# update remote in submodules
git submodule foreach git pull origin master

# set local git user name and email for all submodules
gituname=`git config --local user.name`; gituemail=`git config --local user.email`; git submodule foreach "git config --local user.name $gituname; git config --local user.email $gituemail;"