Skip to content

Instantly share code, notes, and snippets.

@joakim
Forked from rustyio/subgit
Created October 9, 2014 10:22
Show Gist options
  • Save joakim/f69aae59369944982805 to your computer and use it in GitHub Desktop.
Save joakim/f69aae59369944982805 to your computer and use it in GitHub Desktop.
#!/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 "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment