Created
July 13, 2015 15:58
-
-
Save joest67/21783252a816a0a3bf1f to your computer and use it in GitHub Desktop.
Auto update git repo in directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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