Skip to content

Instantly share code, notes, and snippets.

@codegoalie
Created June 3, 2021 19:15
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 codegoalie/45d09a5a0a9fef27dd097eaa5e578ed6 to your computer and use it in GitHub Desktop.
Save codegoalie/45d09a5a0a9fef27dd097eaa5e578ed6 to your computer and use it in GitHub Desktop.
(Re)watch all of your own repos using gh cli
$ gh api graphql --paginate -f query='
query($endCursor: String) {
viewer {
repositories(first: 100, after: $endCursor) {
nodes { nameWithOwner }
pageInfo {
hasNextPage
endCursor
}
}
}
}
' | \
jq '.data.viewer.repositories.nodes|map(.nameWithOwner)[]' | \
sed 's/"//g' | \
xargs -I % gh api --silent -X PUT repos/%/subscription -f subscribed=true
@codegoalie
Copy link
Author

I accidentally had auto-watch team set and joined an organization with almost a thousand repos...
I went to the Watching page page and after individually unwatching like 100 repos, I decided to Unwatch all. Then I wanted to rewatch just my own repos. Turns out the gh cli has an api command to use the GitHub API directly...

It's not everyday I get to compose such a one-liner so I wanted to share it.

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