I realize I watch too many repos in GitHub and the only way I’ve found to unwatch many of them is going to github.com/my_user_name/following, getting inside each of them and pressing Unwatch button.

Isn’t there any way to unwatch them faster and easily?

1

For the lazy, one can do this without the API reasonably quickly at this url: https://github.com/watching

A clean simple list, click click click click.

Additionally, there’s a box that is golden. Uncheck it to not automatically be set to watch all repos you’re given push access to. Hooray for managing the signal to noise ratio.

6

Native JS version of a previous answer. Navigate to https://github.com/watching and then run:

Oneliner:

Array.prototype.slice.apply(document.querySelectorAll('.js-subscription-row')).forEach(el => { const org = el.querySelector('a[href^="/YOUR_ORG"]'); if (org) el.querySelector('button').click()})

Unwrapped:

const org = 'YOUR_ORG'
const query = document.querySelectorAll('.js-subscription-row')
const rows = Array.prototype.slice.apply(query)
rows.forEach(function (el) {
  const org = el.querySelector('a[href^="https://stackoverflow.com/" + org + '"]')
  if (org) el.querySelector('button').click()
})

4

Organization specific

If you just want to unwatch repos from a single organisation, you can use this from https://github.com/watching


$('.js-subscription-row').each(function(){
var isYourOrganisation = $(this).find("a[href^='/YOUR_ORG']");
if(isYourOrganisation.length){
$(this).find('button:contains("Unwatch")').click();
}
});

Substitute YOUR_ORG with whatever your organization is called.

0

I haven’t seen any but, as we have power of the entire universe(in short we are developers). Use their developer API and create a small tool. The API is very descriptive,

http://developer.github.com/

A few comments have mentioned the Unwatch all button at https://github.com/watching

Here’s a picture:

enter image description here

1

I’ve also found a command-line tool that use the GitHub API to unwatch multiple repositories: https://www.npmjs.com/package/github-unwatch-org-repos

I’m not a fan of command-line tools that want my password in plain text on the command line (thus visible to all system users who run ‘ps’ at the right time, and also stored in plain text in ~/.bash_history unless you take extreme care to avoid that), so I haven’t tried it.

I have the same issue, so I’ve created bash script using GitHub API for batching unwatch.

#! /bin/bash

# dry run:
# ./github-unwatch.bash [unwatch repository pattern] [github account] [github token]
#
# execute actually:
# ./github-unwatch.bash [unwatch repository pattern] [github account] [github token] run

set -eu

readonly REPOSITORY_PATTERN="$1"
readonly CREDENTIALS="$2:$3"
readonly RUN="${4:-dry-run}"

page=1
targets=()

while :
do
  result=($( curl 
  -u $CREDENTIALS 
  -H "Accept: application/vnd.github.v3+json" 
  "https://api.github.com/user/subscriptions?per_page=100&page=$page" 
  | jq -r '.[].full_name' ))

  if [[ ${#result[@]} -eq 0 ]]; then
    break
  fi

  for e in "${result[@]}"
  do
    if [[ $e =~ $REPOSITORY_PATTERN ]]; then
      targets+=($e)
    fi
  done

  page=$((++page))
done

if [[ ${#targets[@]} -eq 0 ]]; then
  exit 0
fi
for target in "${targets[@]}"
do
  echo "Unwatch: $target"
  if [[ "$RUN" == "run" ]]; then
    curl 
      -u $CREDENTIALS 
      -X DELETE 
      -H "Accept: application/vnd.github.v3+json" 
      "https://api.github.com/repos/$target/subscription"
  fi
done

Not the answer you’re looking for? Browse other questions tagged github or ask your own question.