Skip to content

Instantly share code, notes, and snippets.

@Rhernandez513
Created October 8, 2015 14:48
Show Gist options
  • Save Rhernandez513/fdf746ccae0e845399b4 to your computer and use it in GitHub Desktop.
Save Rhernandez513/fdf746ccae0e845399b4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# update_repos - A simple script to update git repos within a directory
# Location where this script is stored in the filesystem
# STARTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Location of the working directory of the calling shell
PARENTDIR=$PWD
# Convert from HTTPS to SSH access for cloned repos
for i in */; do
sed -i 's/https\:\/\/github.com\//[email protected]\:/' "$i/.git/config"
done
# Cycles into each directory where the script is called from and updates
echo "Script called from $PARENTDIR"
for DIR in */; do
cd "$DIR"
echo "Updating: $DIR"
git fetch
git pull
cd "$PARENTDIR"
done
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment