Skip to content

Instantly share code, notes, and snippets.

@Revolucent
Last active August 29, 2015 14:21
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 Revolucent/23363571cde9a32a83a1 to your computer and use it in GitHub Desktop.
Save Revolucent/23363571cde9a32a83a1 to your computer and use it in GitHub Desktop.
git-only
#!/bin/bash
# Git Only: Perform a Git operation only when in a whitelisted directory.
#
# This is really only useful when combined with git-gat. For instance, let's
# say we want to create a branch in two of our side-by-side repos, we can say:
#
# git gat only Repo1 Repo2 -- checkout -b feature1
#
# This will create and checkout a branch called feature1, but only in Repo1 and Repo2.
# All other repos that git-gat might have touched are skipped.
REPO=`basename $PWD`;
PERFORM=false;
while [[ ($# -gt 0) && ($1 != --) ]]; do
if [[ $1 == $REPO ]]; then
PERFORM=true;
fi;
shift;
done;
shift; # To get rid of --
if $PERFORM; then
echo "$REPO:";
git "$@";
echo;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment