Skip to content

Instantly share code, notes, and snippets.

@joest67
Created July 13, 2015 15:58
Show Gist options
  • Save joest67/21783252a816a0a3bf1f to your computer and use it in GitHub Desktop.
Save joest67/21783252a816a0a3bf1f to your computer and use it in GitHub Desktop.
Auto update git repo in directory
#!/bin/sh
# source: https://github.com/florianl/AutoUpdateGit/blob/master/AutoUpdateGit.sh
# Change here your basedirectory
# Example:
# Base="/this/is/my/basedirectory"
Base=""
if [ -z "$Base" -o "$Base" == "/this/is/my/basedirectory" ];
then
Base=$(pwd)
fi
echo "BASE: "$Base
for Dir in $(find $Base -maxdepth 1 -type d)
do
if [ -d $Dir/.git ];
then
cd $Dir
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
pwd
remote=$(grep "\[remote" $Dir/.git/config)
if [[ $remote ]];
then
git pull origin master
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment