Skip to content

Instantly share code, notes, and snippets.

@Xerkus
Created October 15, 2025 08:25
Show Gist options
  • Select an option

  • Save Xerkus/1a15dab3eec456f5d5d5b6068a9c182e to your computer and use it in GitHub Desktop.

Select an option

Save Xerkus/1a15dab3eec456f5d5d5b6068a9c182e to your computer and use it in GitHub Desktop.
Bash oneliners to mass clone/update repos from the github org
cd ~/workspace/laminas
# clone
gh repo list laminas --limit 999 --no-archived --json nameWithOwner --jq '.[]|.nameWithOwner' | xargs -I {} bash -c '[ ! -d $(basename {}) ] && echo -e "\n{}" && gh repo clone {} && (cd $(basename {}) && gh repo set-default {} && gh repo fork --remote)'
# checkout moving default branch
for repo in *; do (cd "${repo}" && echo -e "\n${repo}" && git fetch upstream && git remote set-head --auto upstream && git checkout --force $(git rev-parse --abbrev-ref upstream/HEAD | cut -d/ -f2-)); done
# pull changes for checked out branch
for repo in *; do (cd "${repo}" && echo -e "\n${repo}" && git pull upstream --ff-only); done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment