Created
June 27, 2019 10:11
-
-
Save rahulkj/71db9bb451f578840b4d062cc0347be7 to your computer and use it in GitHub Desktop.
Script to transfer all the git repos from one org to another
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 -x | |
export GIT_USER= | |
export GIT_TOKEN= | |
export ORG_NAME= | |
export NEW_ORG_NAME= | |
export OUTPUT_FILE=repos.json | |
rm -rf $OUTPUT_FILE | |
curl -u $GIT_USER:$GIT_TOKEN "https://api.github.com/users/$ORG_NAME/repos" -s > $OUTPUT_FILE | |
REPO_NAMES=$(cat $OUTPUT_FILE | jq -r '.[] | .name') | |
for REPO in $REPO_NAMES | |
do | |
echo "repo is: $REPO" | |
curl -u $GIT_USER:$GIT_TOKEN "https://api.github.com/repos/$ORG_NAME/$REPO/transfer" \ | |
-X POST -d '{"new_owner": "'"$NEW_ORG_NAME"'"}' \ | |
-H "Accept: application/vnd.github.nightshade-preview+json" | |
done | |
rm -rf $OUTPUT_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment