Created
August 4, 2009 00:30
-
-
Save tekkub/160946 to your computer and use it in GitHub Desktop.
Subtree merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Based off of http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html | |
if [[ ! "$2" || ("$3" && ! "$4" ) ]] | |
then | |
filename=`echo "$0"| sed "s/.*\///"` | |
echo "Usage: $filename remote_name repo_url branch_name path_to_merge_to" | |
echo " * Create a new subtree merge" | |
echo " $filename remote_name branch_name" | |
echo " * Pull from remote_name/branch_name into subtree" | |
exit 0 | |
fi | |
if [ "$3" ] | |
then # Create our subtree | |
echo "Creating new subtree merge" | |
name=$1 | |
url=$2 | |
branch=$3 | |
path=$4 | |
git remote add -f $name $url | |
git merge -s ours --no-commit $name/$branch | |
git read-tree --prefix=$path -u $name/$branch | |
git commit -m "Subtree-merge $url branch '$branch' to $path" | |
else # Pull! | |
echo "Performing subtree pull" | |
name=$1 | |
branch=$2 | |
git pull -s subtree $name $branch | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment