This will probably also work for other local Git management systems, although it will only migrate the repository itself, not any other metadata (eg. issues).
NOTE: This will only work if you are an administrator on your Gogs instance, or if an administrator has enabled local repository importing for all users.
First, save the following as
migrate.sh somewhere, and make it executable (
chmod +x migrate.sh):
HOSTNAME="git.cryto.net" BASEPATH="/home/git/old-repositories/projects/joepie91" OWNER_ID="$1" CSRF=`cat ./cookies.txt | grep _csrf | cut -f 7` while read REPO; do REPONAME=`echo "$REPO" | sed "s/\.git\$//"` curl "https://$HOSTNAME/repo/migrate" \ -b "./cookies.txt" \ -H 'origin: null' \ -H 'content-type: application/x-www-form-urlencoded' \ -H "authority: $HOSTNAME" \ --data "_csrf=$CSRF" \ --data-urlencode "clone_addr=$BASEPATH/$REPO" \ --data-urlencode "uid=$OWNER_ID" \ --data-urlencode "auth_username=" \ --data-urlencode "auth_password=" \ --data-urlencode "repo_name=$REPONAME" \ --data-urlencode "description=Automatically migrated from Gitolite" done
HOSTNAME to point at your Gogs installation, and
BASEPATH to point at the folder where your Gitolite repositories live on the filesystem. It must be the entire base path - the repository names cannot contain slashes!
Now save the Gogs cookies from your browser as
cookies.txt, and create a file (eg.
repositories.txt) containing all your repository names, each on a new line. It could look something like this:
project1.git project2.git project3.git
After that, run the following command:
cat repositories.txt | ./migrate.sh 1
… where you replace
1 with your User ID on your Gogs instance.