Skip to content

Instantly share code, notes, and snippets.

@Thermoflux
Forked from mnem/git_fetch_pull_all_subfolders.sh
Last active February 27, 2020 16:54
Show Gist options
  • Save Thermoflux/add8ccb8c1e58d1fd9f5d09de08a7a45 to your computer and use it in GitHub Desktop.
Save Thermoflux/add8ccb8c1e58d1fd9f5d09de08a7a45 to your computer and use it in GitHub Desktop.
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Use this script to update the repositories in directory 'REPOSITORIES'
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES="/home/rstudio/ForteAegis/Code/"
IFS=$'\n'
for REPO in `ls "$REPOSITORIES/"`
do
if [ -d "$REPOSITORIES/$REPO" ]
then
echo "Updating $REPOSITORIES/$REPO at `date`"
if [ -d "$REPOSITORIES/$REPO/.git" ]
then
cd "$REPOSITORIES/$REPO"
git status
echo "Fetching"
git fetch
echo "Pulling"
git pull
else
echo "Skipping because it doesn't look like it has a .git folder."
fi
echo "Done at `date`"
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment