Skip to content

Instantly share code, notes, and snippets.

@maxsilver
Created October 27, 2011 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maxsilver/1319846 to your computer and use it in GitHub Desktop.
Save maxsilver/1319846 to your computer and use it in GitHub Desktop.
Import Gitosis to GitHub
#!/bin/bash
# A simple script to pull a repo off an old host
# (such as git@git.example.com:repo1.git)
# and import it as private repo to github organization
# (git@github.com:example_organization/repo1.git)
# Example Usage ==> ./github-import.sh repo1 repo2 repo3
REPO_NAME=$1
OLD_PATH="git@git.example.com:"
ORGANIZATION="townsquare"
GITHUB_USER="maxsilver"
GITHUB_PASS="password"
GITHUB_TEAM_ID="555" #get your team id from the api
for ARG in $*
do
REPO_NAME=$ARG
echo "------- Starting Import for $REPO_NAME ---------"
# Make the repo (privately)
curl -u "$GITHUB_USER:$GITHUB_PASS" -d "{ \"name\": \"$REPO_NAME\", \"public\": false}" https://api.github.com/orgs/$ORGANIZATION/repos
# Assign the repo to the team
curl -u "$GITHUB_USER:$GITHUB_PASS" -X PUT -d "$REPO_NAME" "https://api.github.com/teams/$GITHUB_TEAM_ID/repos/$ORGANIZATION/$REPO_NAME"
# Pull the repo down from old host, and push it to new github repo
git clone --bare "$OLD_PATH$REPO_NAME.git" && cd "$REPO_NAME.git" && git push --mirror "git@github.com:$ORGANIZATION/$REPO_NAME.git" && cd ..
echo " -- $REPO_NAME completed, moving along... "
echo ""
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment