#!/bin/bash # replace these with your own GITEA_API_KEY=***API_token*** GITEA_API_ENDPOINT=https://git.sa.vin/api/v1 REPO_DIR=/home/mason/Desktop/gitea-repositories/masonite-studios #replace it with your old repo path SSH_REPO=ssh://git@git.sa.vin:2222 USER=masonite-studios for dir in $REPO_DIR/*.git; do if [ -d "$dir" ]; then # naming the repo REPO=$(basename $dir .git) # create repo in Gitea #curl -H "content-type: application/json" -H "Authorization: token $GITEA_API_KEY" -X POST -d '{"Name":"'$REPO'","private":true}' $GITEA_API_ENDPOINT/user/repos curl -H "content-type: application/json" -H "Authorization: token $GITEA_API_KEY" -X POST -d '{"Name":"'$REPO'","private":true}' $GITEA_API_ENDPOINT/orgs/$USER/repos echo "Created $REPO in Gitea." # change directory to old repo cd $dir # set new origin git remote add origin $SSH_REPO/$USER/$REPO.git git remote set-url origin $SSH_REPO/$USER/$REPO.git # push all from old repo to Gitea git push --all origin # change back to home directory cd ../ fi done