Skip to content

Instantly share code, notes, and snippets.

@Kornel
Created February 12, 2016 08:28
Show Gist options
  • Save Kornel/12977767391bf0073549 to your computer and use it in GitHub Desktop.
Save Kornel/12977767391bf0073549 to your computer and use it in GitHub Desktop.
Pull all git subdirectories - if successful, be quiet.
#!/usr/bin/env bash
quiet_git() {
tempfile=`mktemp /tmp/git-pull-all-XXXXXXXX`
stdout=$tempfile
stderr=$tempfile
if ! git "$@" </dev/null >$stdout 2>$stderr; then
cat $stderr >&2
rm -f $stdout $stderr
fi
rm -f $stdout $stderr
}
export -f quiet_git
for i in `find . -type d -depth 1`
do
if [ -d $i/.git ]
then
echo "Pulling ${i}"
quiet_git -C $i pull
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment