Created
January 5, 2012 05:17
-
-
Save phooky/1563831 to your computer and use it in GitHub Desktop.
A simple wrapper script for git that tracks cloned repositories and implements "git pull-all" to do a git pull in each such repository.
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 | |
# | |
# Git wrapper for tracking cloned repositories and implementing | |
# "pull-all" to update all cloned repositories from their origins. | |
# | |
# Add the following to your bashrc to enable: | |
# alias git=/PATH/TO/git-wrapper.sh | |
# Todo: parse out options to clone to avoid completely messing up | |
GIT_MEMO_FILE=~/.git-pulls | |
GIT_BINARY=/usr/bin/git | |
if [ "pull-all" = "$1" ] | |
then | |
echo "Pulling all cloned repositories." | |
while read REPO ; do | |
pushd ${REPO} | |
${GIT_BINARY} pull | |
popd | |
done < ${GIT_MEMO_FILE} | |
exit 0 | |
fi | |
${GIT_BINARY} $* | |
if [ $? = 0 ] | |
then | |
EXTRACT_DIR='s/.*\/\([^\.]*\)\.git.*/\1/' | |
if [ "clone" = "$1" ] | |
then | |
if [ -n "${3}" ] | |
then | |
memoize_dir="${3}" | |
else | |
memoize_dir=`echo ${2} | sed ${EXTRACT_DIR}` | |
fi | |
memoize_dir=`pwd`/${memoize_dir} | |
echo "Tracking clone ${memoize_dir}." | |
echo ${memoize_dir} >> ${GIT_MEMO_FILE} | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment