Skip to content

Instantly share code, notes, and snippets.

@pentago
Created January 13, 2023 11:22
Show Gist options
  • Save pentago/8ba78c3289e3e7640b886f1cc4e6f5d8 to your computer and use it in GitHub Desktop.
Save pentago/8ba78c3289e3e7640b886f1cc4e6f5d8 to your computer and use it in GitHub Desktop.
Bitbucket to Github repo migration shell function
# Bitbucket to Github Migration
bb2gh() {
echo "Cloning repo"
git clone $1 $2
echo
echo "Entering repo directory"
cd $2
echo
echo "Adding remote"
git remote add upstream $3
echo
echo "Fetching all remote branches"
for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done
echo
echo "Pushing"
git push --all upstream
git push --tags upstream
echo
echo "Setting Origin URL"
git remote set-url origin $3
echo
echo "Mirroring"
git push --mirror
cd ..
echo "Complete"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment