Useful commands and scripts
-
Git Pull on multiple repos
If you have multiple repositories in a single directory you can execute git pull on all of the repos using one command. You should be in the directory when running this command.
find . -type d -name ".git" -execdir git pull \;
-
Clone all repos in an organisation
This script clones all repos in an organisation. You should generate a PAT token and authorise it for that specific org. After that you can
#!/bin/bash USERNAME="" # GitHub username ORG_NAME="" # name of the organisation you are part of GITHUB_TOKEN="" # GitHub token PAT all_urls=() page=1 while true; do urls=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ "https://api.github.com/orgs/$ORG_NAME/repos?per_page=100&page=$page" | \ jq -r '.[].clone_url' | grep mms) [[ -z "$urls" ]] && break all_urls+=($urls) ((page++)) done for url in "${all_urls[@]}"; do git clone "https://${USERNAME}:${GITHUB_TOKEN}@${url:8}" done