Skip to content

Instantly share code, notes, and snippets.

@digi0ps
Created November 30, 2019 17:27
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 digi0ps/c547dddbaaccd88f41ec5cea7cbfbf6d to your computer and use it in GitHub Desktop.
Save digi0ps/c547dddbaaccd88f41ec5cea7cbfbf6d to your computer and use it in GitHub Desktop.
Python script to unwatch all repositories of an organization.
from github import Github
# pip install PyGithub
ORG_NAME = 'YOUR_ORG'
ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN'
g = Github(ACCESS_TOKEN)
me = g.get_user()
watching_repos = list(me.get_watched())
watching_orgs_repos = [r for r in watching_repos if r.owner.login == ORG_NAME]
print(f'Total repos watched by {me.login}: {len(watching_repos)}')
print(f'Total {ORG_NAME}\'s repos watched by {me.login}: {len(watching_orgs_repos)}\n')
for repo in watching_orgs_repos:
print(f'Unsubscriping from {repo.full_name}')
me.remove_from_watched(repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment