Last active
August 29, 2015 14:20
-
-
Save mpycio/0df4feaec0564d94e4a7 to your computer and use it in GitHub Desktop.
import git repository to new remote
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
Counting objects: 912, done. | |
Delta compression using up to 8 threads. | |
#!/bin/bash | |
# check if user passed name of the new remote repository | |
if [ -z "$1" ] | |
then | |
echo "No bitbucket repository name supplied" | |
exit 1 | |
fi | |
# check if command was run from a git repository | |
git status &> /dev/null | |
if [ $? -ne 0 ] | |
then | |
echo "Command must be run from git repository." | |
exit $? | |
fi | |
for remote in `git branch -r | grep -v HEAD`; do | |
git checkout --track $remote; | |
done | |
git checkout master | |
git remote add bitbucket git@bitbucket.org:graymatterltd/$1.git | |
[ $? -ne 0 ] || exit $?; | |
git push --all bitbucket | |
git push –tags bitbucket | |
git remote rm bitbucket | |
git remote set-url origin git@bitbucket.org:graymatterltd/$1.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment