Unwatch All Repositories in a GitHub Organization

Created on .

Read in 2 minutes.

I am currently changing teams at Google and need to unsubscribe from all repositories in my former GitHub organization. This is possible to do at github.com/watching, but as always, I want to avoid a bunch of clicks. This will require a few steps:

  1. Find existing subscriptions using the Github API.
  2. Filter out subscriptions that are not in the organization.
  3. Unsubscribe from each repository.

I’m planning to use the GitHub cli to make this a little smoother.

gh api --paginate "https://api.github.com/user/subscriptions" |
| jq '.[] | .full_name' \
| grep googlemaps \
| sort

I was subscribed to the following repositories in the GitHub organization.

"googlemaps/.github"
"googlemaps/android-maps-rx"
"googlemaps/android-places-ktx"
"googlemaps/google-maps-services-go"
"googlemaps/google-maps-services-python"
"googlemaps/googlemaps.github.io"
"googlemaps/js-api-loader"
"googlemaps/js-jest-mocks"
"googlemaps/js-markerclustererplus"
"googlemaps/js-markermanager"
"googlemaps/js-markerwithlabel"
"googlemaps/js-ogc"
"googlemaps/js-polyline-codec"
"googlemaps/js-samples"
"googlemaps/js-three"
"googlemaps/js-types"
"googlemaps/openapi-specification"
"googlemaps/react-wrapper"
"googlemaps/v3-utility-library"

Now all I had to do was pipe this into another gh api command to delete the subscription.

gh api --paginate "https://api.github.com/user/subscriptions" |
| jq '.[] | .full_name' \
| grep googlemaps \
| xargs -I {} \
gh api \
-X DELETE \
"https://api.github.com/repos/{}/subscription"

Now when I go to one of the repositories, I see that I am only subscribed to “Participating and @mentions” instead of “All Activity”.

GitHub watch notifications menu

GitHub watch notifications menu


Next

2022 Mace's Hideout 100 Race Report

Previous

Strava Webhooks with Stokehook.com

Related


Get the RSS feeds: All, Run, Code.