The gitea issue #5917 discusses how to make multiple users unwatch a repository. It has inspired to write the steps down, as it was not entirely obvious to me.

There was a change introduced via PR #5852 released that added an option AUTO_WATCH_NEW_REPOS into the Gitea config file, but it's default is true.

The consequence of this behavior is, that unless you are running a Gitea at least version 1.8.0, where this config option was introduced and subsequently you have set the AUTO_WATCH_NEW_REPOS to false beforehand, creating a repository (presumably in an Organization) and assigning a team to it makes all the users in that team watch the repository, which creates a lot of noise for the users.

This guide shows how to reduce this noise, it can be adapted for other purposes that require raw SQL commands to be run on PostgreSQL inside Docker.

  • The guide assumes the docker-compose.yml file is identical to the Gitea docs
version: "3"

    external: false

    image: gitea/gitea:1.13.3
    container_name: gitea
      - USER_UID=1000
      - USER_GID=1000
+     - DB_TYPE=postgres
+     - DB_HOST=db:5432
+     - DB_NAME=gitea
+     - DB_USER=gitea
+     - DB_PASSWD=gitea
    restart: always
      - gitea
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - "3000:3000"
      - "222:22"
+    depends_on:
+      - db
+  db:
+    image: postgres:9.6
+    restart: always
+    environment:
+      - POSTGRES_USER=gitea
+      - POSTGRES_PASSWORD=gitea
+      - POSTGRES_DB=gitea
+    networks:
+      - gitea
+    volumes:
+      - ./postgres:/var/lib/postgresql/data

The following steps have to be modified if changes were made the lines with different color, specifically converting host, user, password and DB.

  • If the instance is not running already, start it (assuming all the other configuration is done according to docs)
docker-compose up -d
  • Connect to psql inside a container and prompt postgres password from above
docker-compose run --rm db psql -h db -U gitea gitea

The command could be a little confusing, so here are placeholders

docker-compose run --rm SERVICE psql -h HOST -U USER DB
  • Now you can use standard psql commands, use database gitea
\c gitea

Then for instance list all tables

  • Look up repository id
SELECT id,name FROM repository ORDER BY name;

Disclaimer: following commands can lead to a LOSS OF DATA! Before proceeding further, please make proper backup(s).

  • Remove all the watchers of the given repository, insert change ID to a required value
DELETE FROM watch WHERE repo_id=ID;


This is a 14th post of #100daystooffload.