Skip to content

Instantly share code, notes, and snippets.

@rustyio
Created January 24, 2010 18:48
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save rustyio/285365 to your computer and use it in GitHub Desktop.
Save rustyio/285365 to your computer and use it in GitHub Desktop.
subgit
#!/usr/bin/env sh
# subgit
#
# A tiny wrapper around git to help you manage
# Git sub-projects easily, safely, and simply.
#
# Created by Rusty Klophaus (@rklophaus)
#
# See http://rklophaus.com/subgit for usage.
if [ "$1" == "setup" ]; then
if [ -d ".git" ]; then
mv .git .subgit
echo "Converted to a subgit repository."
exit 0
else
echo "Could not find .git directory."
exit -1
fi
fi
DIR=`pwd`
while [ ! -d "$DIR/.subgit" ] && [ ! "$DIR" == "/" ]; do
DIR=`dirname $DIR`
done
if [ $DIR == "/" ]; then
echo "Not in a subgit repository!"
exit -1
fi
git --git-dir=$DIR/.subgit "$@"
@assumptionsoup
Copy link

Does anyone know a way to get bash tab completion to work with this? I've been trying to get it to work for a while now with no success.

@johnilacqua
Copy link

For anyone who wants to use this script, I'd recommend changing line 33 to
git --git-dir="$DIR/.subgit" --work-tree="$DIR" "$@"
otherwise it doesn't work properly if you're in a subdirectory within the subgit repo.

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