Skip to content

Instantly share code, notes, and snippets.

@dynnamitt
Last active March 15, 2022 09:17
Show Gist options
  • Save dynnamitt/b342f726e4b1415cbd1965aa42b1fb13 to your computer and use it in GitHub Desktop.
Save dynnamitt/b342f726e4b1415cbd1965aa42b1fb13 to your computer and use it in GitHub Desktop.
GITLAB ::: git-clone ALL favs into deep-nested dirs (( curl | jq | parallel ))
#!/bin/sh
# Make sure you have a PRIVATE_TOKEN in the file ~/.gitlab_token
GL_TOKEN=$(cat ~/.gitlab_token)
[ -z $GL_TOKEN ] && (printf "\n\nno token!\n\n\n";exit 1)
# USERID from username ARG1 on command-line
USER_NAME=${1:-kjetil.midtlie}
USERID=$(curl "https://gitlab.com/api/v4/users?private_token=$GL_TOKEN&username=$USER_NAME" | jq -r '.[0]|.id')
ENDPOINT=starred_projects
#ENDPOINT=projects
cd ~
curl "https://gitlab.com/api/v4/users/$USERID/$ENDPOINT?per_page=100&private_token=$GL_TOKEN" \
| jq -r '.[] | .ssh_url_to_repo + "\t" + .path_with_namespace' \
| parallel --colsep '\t' git clone {1} {2}
@dynnamitt
Copy link
Author

dynnamitt commented Nov 22, 2021

git pull like this (from same root)
cd $HOME && find . -name '.git' -exec dirname {} \; | parallel git -C {} pull -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment