Pull all your Git Repositories
This shell script will pull all the Git repositories in a specific folder.
#!/bin/bash
dirhtd=/Users/kevin/websites/htdocs/*
for f in $dirhtd
do
# Go to folder
cd $f;
# Check if it's a git repository
if test -d ".git/"; then
# Display repository name
echo -e "\033[33m "$f" \033[0m";
# Check repository status
status=`git status -s`;
# Git says nothing
if [ -z "$status" ]
then
# Pull latest changes
echo "- Pull";
git pull --rebase;
else
# Do nothing
echo "- Can’t pull";
fi
fi
done
Written by Kévin / Darklg
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#