Skip to content

Instantly share code, notes, and snippets.

@mpycio
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpycio/0df4feaec0564d94e4a7 to your computer and use it in GitHub Desktop.
Save mpycio/0df4feaec0564d94e4a7 to your computer and use it in GitHub Desktop.
import git repository to new remote
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