-
-
Save wimvds/1103786 to your computer and use it in GitHub Desktop.
./moveToGitHub <githuburl>
This file contains 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 | |
export $GITHUBURL="$1" | |
# clean up remote branch list | |
git fetch origin; git remote prune origin | |
# delete all local branches except master | |
git checkout master; git pull; git branch | while read repo; do branch=`echo "$repo" | cut -d" " -f 2`; if [ ! $branch == 'master' ]; then git branch -D $branch; fi; done; git gc | |
# checkout and track all remote branches | |
git branch -r | grep origin | while read repo; do if [[ $repo != *HEAD* ]]; then git checkout -t $repo; fi; done | |
# rename the remote origin to kunstmaan | |
git remote rename origin kunstmaan | |
# add a new origin on github | |
git remote add origin $GITHUBURL | |
# loop over all banches that are not in feature/ exept master and develop and rename them to feature/ | |
git branch | grep -v feature | while read repo; do branch=`echo "$repo" | cut -d" " -f 2`; if [ ! $branch == 'develop' ] && [ ! $branch == 'master' ]; then git branch -m $branch feature/$branch; fi; done | |
# send the branches to github | |
git branch | while read repo; do branch=`echo "$repo" | cut -d" " -f 2`; git push -u origin $branch; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment