Skip to content

Instantly share code, notes, and snippets.

@effkay
Created November 12, 2009 10:34
Show Gist options
  • Save effkay/232792 to your computer and use it in GitHub Desktop.
Save effkay/232792 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Author: Michale Kessler http://github.com/netzpirat
echo "Migrate all git repositories to github"
for repo in `ls -l | grep "^d" | awk '{ print $9 }'`
do
echo "-----------------------------------------------------------"
echo "Checking ${repo}"
cd $repo
if [ -d .git ]; then
origin=`git remote -v | grep origin | grep fetch | awk '{ print $2}'`
if [[ $origin =~ 'git.screenconcept.ch' ]]; then
echo "Switch origin to github"
git remote rm origin
git remote add origin git@github.com:screenconcept/${repo}.git
echo "Pull latest changes from github"
git pull origin master
if [ -f .gitmodules ]; then
echo "Check submodules"
firstmodule=`grep git.screenconcept.ch .gitmodules | head -n 1 | awk '{ print $3}'`
if [[ $firstmodule =~ 'git.screenconcept.ch' ]]; then
echo "Hey. We have to migrate the submodules"
sed -e 's/ssh:\/\/git\.screenconcept\.ch\/var\/git/git@github.com:screenconcept/g' .gitmodules
git commit -m "Migrate Screen Concept modules to github" .gitmodules
git push origin master
git submodule init
git submodule update
else
echo "Update modules, just to make sure ;-)"
git submodule init
git submodule update
fi
fi
echo "Pushing now your changes..."
git push origin master
echo "Migration done!"
else
echo "Skip it! It's hosted at ${origin}!"
fi
else
echo "SKIP. Is not a git repository"
fi
cd ..
done
echo "-----------------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment