Skip to content

Instantly share code, notes, and snippets.

@takashicompany
Last active October 8, 2018 08:44
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 takashicompany/4861504c123e5b2c0778fc4d411f27e6 to your computer and use it in GitHub Desktop.
Save takashicompany/4861504c123e5b2c0778fc4d411f27e6 to your computer and use it in GitHub Desktop.
git-subtree support shell.
#!/bin/bash
repo=<subtree-repo path>
remote=<subtree-repo remote name>
branch=<subtree branch>
path=<local subtree path>
if [ $# -eq 0 ]; then
echo "this is git-subtree-suppot tool.\noptions:\n init\n pull\n push"
exit 1
fi
if [ $1 = init ]; then
git remote add ${remote} ${repo}
git fetch ${remote}
git subtree add --prefix=${path} ${remote} ${branch}
elif [ $1 = pull ] ; then
git subtree pull --prefix=${path} ${remote} ${branch}
elif [ $1 = push ] ; then
git subtree push --prefix=${path} ${remote} ${branch}
else
echo "$1 option not found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment