You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tristan F. edited this page Nov 11, 2013
·
3 revisions
Here are some useful tips and tricks
Aborting on error
If you want your receiver script to stop if any command fails (For instance, during a deployment or a test suite), just put this in the beginning of your bash script and it will abort on any error.
set -e
Handling submodules
As submodules are references to other git repositories, they are not pushed with your git push. If you are using gitreceive as a part of your deployment workflow, you might want to include these, and here is how; in your receive script, just include the following :
echo"----> Unpacking"
mkdir -p /tmp/deploy && cat | tar -x -C /tmp/deploy
cd /tmp/deploy
echo"----> Getting submodules"# We reinitialize .git to avoid conflicts
rm -fr .git
# GIT_DIR is previously set by gitreceive to ".", we want it back to default for thisunset GIT_DIR
git init .# We read the submodules from .gitmodules
git config -f .gitmodules --get-regexp '^submodule\..*\.path$'|whileread path_key path
do
rm -fr $path
url_key=`echo $path_key| sed 's/\.path/.url/'`
url=`git config -f .gitmodules --get "$url_key"`# $3 is the username# Change it if needed
git submodule add $3@$url$pathdone
That way, each one of your submodule will be cloned & updated properly.