Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active June 27, 2022 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cderv/eac2e630a4bde09dfbe0bd6d213140aa to your computer and use it in GitHub Desktop.
Save cderv/eac2e630a4bde09dfbe0bd6d213140aa to your computer and use it in GitHub Desktop.
Update all repos from an organisation on github
$repos = gh repo list 'quarto-journals' --no-archived --source --json owner,name,defaultBranchRef -q '.[] | {org: .owner.login, repo: .name, branch: .defaultBranchRef.name}' | ConvertFrom-Json
foreach($row in $repos) {
echo "Looking for $($row.repo) folder"
if (Test-Path -Path $row.repo) {
git -C "$($row.repo)" checkout $row.branch
git -C "$($row.repo)" pull origin $row.branch
} else {
gh repo clone "$($row.org)/$($row.repo)"
}
}
echo "All repos updated!"
#!/bin/bash
repos=$(gh repo list 'quarto-journals' --no-archived --source --json owner,name,defaultBranchRef -q '.[] | {org: .owner.login, repo: .name, branch: .defaultBranchRef.name}')
echo $repos
for row in $(echo "${repos}"); do
repo=$(echo ${row} | jq -r '.repo')
branch=$(echo ${row} | jq -r '.branch')
org=$(echo ${row} | jq -r '.org')
echo "Looking for ${repo} folder"
if [ -d "$repo" ]; then
git -C "$repo" checkout $branch
git -C "$repo" pull origin $branch
else
gh repo clone "${org}/${repo}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment