Created
January 11, 2016 12:54
-
-
Save iledarn/fdd4b086cf0605f71013 to your computer and use it in GitHub Desktop.
Bash script for copying folders from git repo A to git repo B with history
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 | |
source_repo=$PWD | |
echo $source_repo | |
if [ -n "$1" ] | |
then | |
module=$1 | |
echo $module | |
else | |
echo "Must be module name" | |
exit $E_WRONGARGS | |
fi | |
if [ -n "$2" ] | |
then | |
dest_repo=$2 | |
echo $dest_repo | |
else | |
echo "Must be dest_repo" | |
exit $E_WRONGARGS | |
fi | |
if [ -n "$3" ] | |
then | |
branch=$3 | |
echo $branch | |
else | |
echo "Must be branch specified" | |
exit $E_WRONGARGS | |
fi | |
cp -r $source_repo ../$module | |
cd ../$module | |
git remote rm origin | |
git filter-branch --subdirectory-filter $module -- --all | |
mkdir $module | |
mv * $module | |
git add . | |
git commit -m "[MOV] module -- $module" | |
cd $dest_repo | |
git remote add repo_moved_module $source_repo/../$module | |
git pull repo_moved_module $branch --no-edit | |
git remote rm repo_moved_module | |
rm -rf $source_repo/../$module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment