Skip to content

Instantly share code, notes, and snippets.

@supermethod
Forked from douglas/update_git_repos.sh
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermethod/6449e2808d0cea85edef to your computer and use it in GitHub Desktop.
Save supermethod/6449e2808d0cea85edef to your computer and use it in GitHub Desktop.
Update all svn repos in a directory, supports nested directory structure
#!/bin/bash
set -eu
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
GIT_DIRS=$(find . -name ".git")
# Find all git repositories and update it to the master latest revision
for i in ${GIT_DIRS[*]}; do
DIR=$(echo $i | ggrep -Po '(?<=\.\/).*(?=\.git)')
# We have to go to the .git parent directory to call the pull command
cd "$DIR"
# finally update from svn
echo -e "\033[33mRebasing: $DIR...\033[0m"
if ! git svn rebase; then
echo -e "\033[31mError updating. git status:\033[0m"
git status -sb
fi
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo -e "\n\033[32mComplete!\033[0m\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment