Created
          November 12, 2009 10:34 
        
      - 
      
 - 
        
Save effkay/232792 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
    
  
  
    
  | #!/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