Skip to content

Instantly share code, notes, and snippets.

@ayushgoel
Last active August 29, 2015 14:08
Show Gist options
  • Save ayushgoel/9af1e69bf0f544e1b79b to your computer and use it in GitHub Desktop.
Save ayushgoel/9af1e69bf0f544e1b79b to your computer and use it in GitHub Desktop.
Easily add git subtree
#!/usr/bin/env bash
if [ $# -lt 2 ]
then
echo "ERROR: Less arguments."
echo "Usage: git-subtree-add <git-url> <ref(commit)>"
else
REPO_NAME=`echo $1 | sed 's%^.*/\([^/]*\)\.git$%\1%g'`
echo "Adding subtree for "
echo $REPO_NAME
PREFIX="lib/"$REPO_NAME
git subtree add --prefix=$PREFIX --squash $1 $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment