Skip to content

Instantly share code, notes, and snippets.

@wbingli
Created April 1, 2014 20:28
Show Gist options
  • Save wbingli/9922456 to your computer and use it in GitHub Desktop.
Save wbingli/9922456 to your computer and use it in GitHub Desktop.
Merge multiple repositories into one, keep all commit history
mkdir ~/tdv-core
cd ~/tdv-core
#clone all repos
git clone git@bitbucket.org:tdigital-ondemand/tdv-core.git
#Clone parent firstly
git clone git@bitbucket.org:tdigital-ondemand/parent.git
cd parent
git checkout dev
cd ../tdv-core
git remote add parent ../parent
git pull --no-edit parent dev
git remote rm parent
cd ..
rm -rf parent
#billing-account-management customer-insite-management customer-problem-manager customer-self-management resource-order-manager-oot service-order-manager
#Merge foundation
for repo in foundation canonical-data-model badsanta billing-account-management customer-insite-management customer-problem-manager customer-self-management resource-order-manager-oot service-order-manager product-catalog-manager customer-information-management
do
git clone git@bitbucket.org:tdigital-ondemand/$repo.git
cd $repo
git checkout dev
existing=`ls`
mkdir $repo
for d in $existing
do
git mv $d $repo/
done
#Don't forget .gitignore
git mv .gitignore $repo/
git commit -m "Prepare $repo to merge into tdv-core"
cd ../tdv-core
git remote add $repo ../$repo
git pull --no-edit $repo dev
git remote rm $repo
cd ..
rm -rf $repo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment