Gitlab, as far as I know, does not have a quick-and-dirty area for snippets in the fashion of Gists on GitHub. My choice was to stick all my gists in a single repository. Here is how I got it done.
This script saves to the current directory all your gists, each to its named folder with an additional file “description” with the gist description since I couldn’t find it inside the git repo for a gist.
#!/usr/bin/env python # Filename: get-my-gists.py # Location: gitlab, probably # Author: Chris Arndt (stackoverflow uid 39275), bgstack15 # Startdate: 2018-06-05 21:49 # Title: Script That Downloads GitHub Gists in a Nice Format # Purpose: To facilitate my departure from GitHub # History: # Usage: ./get-my-gists.py bgstack15 # Reference: # copied from https://stackoverflow.com/questions/6724490/pull-all-gists-from-github/34052242#34052242 # Improve: # -*- coding: utf-8 -*- """Clone all gists of GitHub username given on the command line.""" import subprocess import sys import requests if len(sys.argv) > 1: gh_user = sys.argv else: print("Usage: get-my-gists.py ") sys.exit(1) req = requests.get('https://api.github.com/users/%s/gists' % gh_user) for gist in req.json(): # get attributes name = gist['files'].keys() descrip = gist['description'] # debugging print name + ": " + descrip # clone the repo ret = subprocess.call(['git', 'clone', gist['git_pull_url'], name]) if ret != 0: print("ERROR cloning gist %s. Please check output." % gist['id']) # save description with open(name + "/" + "description", "w") as text_file: text_file.write(descrip)
Once I had all my gist directories there, I cleaned up their .git directories, and made a new git repo and uploaded it to gitlab.
rm -rf */.git/ git init git add . -m 'initial retrieval from github gists' git remote add origin https://gitlab.com/bgstack15/former-gists.git git push --set-upstream origin master