Manage your GitHub repository subscriptions from the command line. List organizations you're subscribed to, view repos within an organization, and bulk unsubscribe.
This script was created when I took a new job, and my notification settings inadvertently subscribed me to all 600+ of their repos. I wanted a better signal to noise ratio in my notifications, but I didn't want to click the "Unwatch All" button, which would remove my subscriptions to repos outside my new employer's org.
-
Create a Personal Access Token with the
notificationsscope -
Copy code and build a local venv for
requests:
cd /path/to/script_dir/
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt- Export your token:
export GITHUB_PERSONAL_ACCESS_TOKEN=<your-token-here>$ ./main.py -h
usage: main.py [-h] [--token TOKEN] {list,repos,unsubscribe} ...
Manage GitHub repository subscriptions
positional arguments:
{list,repos,unsubscribe}
list List all organizations you are subscribed to
repos List all repos you are subscribed to in an organization
unsubscribe Unsubscribe from all repos in an organization
options:
-h, --help show this help message and exit
--token, -t TOKEN GitHub Personal Access Token (default: GITHUB_PERSONAL_ACCESS_TOKEN env var)$ ./main.py list
GET https://api.github.com/user/subscriptions?per_page=100&page=1
You are subscribed to repos from 5 organizations/users:
my-company: 42 repo(s)
some-org: 8 repo(s)
another-org: 3 repo(s)
cool-project: 2 repo(s)
random-user: 1 repo(s)
Total: 56 subscriptions$ ./main.py repos some-org
GET https://api.github.com/user/subscriptions?per_page=100&page=1
Subscribed to 3 repos in 'some-org':
- some-org/api-service
- some-org/frontend
- some-org/docs$ ./main.py unsubscribe some-org
GET https://api.github.com/user/subscriptions?per_page=100&page=1
Found 3 subscribed repos in 'some-org':
- some-org/api-service
- some-org/frontend
- some-org/docs
Unsubscribe from the above 3 repositories? (y/n): y
DELETE https://api.github.com/repos/some-org/api-service/subscription
204
DELETE https://api.github.com/repos/some-org/frontend/subscription
204
DELETE https://api.github.com/repos/some-org/docs/subscription
204Use --yes or -y to skip the confirmation prompt.
Note
Forked from: https://gist.github.com/benwillkommen/b7549414883087923ad574d1e846c5f9
Updated code and dependencies to be compatible with Python 3.14 and added a bit more support to list organizations and repos