Skip to content

Instantly share code, notes, and snippets.

@kenny-evitt
Created December 1, 2014 20:26
Show Gist options
  • Save kenny-evitt/8b1b1f905f5a07f016c9 to your computer and use it in GitHub Desktop.
Save kenny-evitt/8b1b1f905f5a07f016c9 to your computer and use it in GitHub Desktop.
Run Git command for all repositories in a directory
#!/bin/sh
if [ ! "$1" = "" ] ; then
if [ "$GITREPO" = "" -a -d "/c/@Kiln" ] ; then
GITREPO="/c/@Kiln"
fi
if [ "$GITREPO" != "" ] ; then
echo "Git repositories found in $GITREPO"
echo "-------"
DIRS="`/bin/ls -1 $GITREPO`"
for dir in $DIRS ; do
if [ -d $GITREPO/$dir/.git ] ; then
echo "$dir -> git $1"
cd $GITREPO/$dir ; git $@
echo
fi
done
else
echo "Git repositories not found."
fi
fi
@kenny-evitt
Copy link
Author

I added the following to my .bashrc:

alias argit='/c/@tools/run-git-command-for-all-repos.sh'

So I can run argit branch in the parent directory of my Git repo root directories (e.g. C:@kiln) to list all of the branches for all of my Git repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment