Created
March 29, 2011 18:25
-
-
Save mbklein/892930 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
framework=$1 | |
project=$2 | |
remote=$3 | |
if [[ ! ("$#" -eq 3)]] | |
then | |
echo >&2 "Usage: $0 <framework-repo> <project-name> <project-repo>" | |
exit 1 | |
fi | |
echo "Cloning framework: $1" | |
echo " into project $2" | |
echo " with new origin repo $3" | |
git clone $framework $project | |
cd $project | |
git submodule init && \ | |
git submodule update && \ | |
git remote rename origin source && \ | |
git branch --track framework-source source/master && \ | |
git remote add origin $remote && \ | |
git push origin master && \ | |
git checkout framework-source && \ | |
git branch --force --set-upstream master origin/master && \ | |
git checkout master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above script will:
<framework-repo>
into a<project-name>
working directory<framework-repo>
<project-repo>
<project-repo>
master branchFrom that point forward, you do all your work in branches, merge into master, push to origin, etc. just like always. Never commit or merge to framework-source. When you want to pull upstream changes into master:
It's not as painful as it looks, except for the conflict resolution, which is always a pain. Steps 1-6 could be pretty easily encapsulated in a shell script, but the rest is too potentially destructive to trust to an automated process.
It's been pointed out that this looks a lot like subtree merging, and it does. But the subtree strategy assumes you want to include the contents of an independent project in a subdirectory of your repo, and doesn't really help when you want to fork and pull from/to the root.