Removing an APT repository on Debian means removing the source definition that points APT at that repository, then refreshing package metadata so future installs and upgrades use only the remaining enabled sources. A clean removal leaves no matching entry under /etc/apt/sources.list.d/ and no stale keyring that is used only by the removed repository.
Current Debian systems commonly keep third-party repositories in deb822 *.sources files under /etc/apt/sources.list.d/. Older entries may use *.list files instead, so search the source directory first and remove the exact file that owns the repository URI.
The example below removes a repository for packages.example.net and its dedicated keyring. Replace the URI, source file, and keyring path with the repository being retired, and keep any package removal or downgrade as a separate decision after the repository itself has been disabled.
Related: How to add an APT repository on Debian
Related: How to install a package on Debian with apt
Related: How to pin a Debian package version
$ grep -R --line-number --fixed-strings "packages.example.net" /etc/apt/sources.list.d/ /etc/apt/sources.list.d/examplecorp.sources:2:URIs: https://packages.example.net/debian
Use a distinctive part of the repository URL. If more than one file matches, inspect each match before removing anything.
$ sudo sed -n '1,120p' /etc/apt/sources.list.d/examplecorp.sources Types: deb URIs: https://packages.example.net/debian Suites: trixie Components: stable Signed-By: /etc/apt/keyrings/examplecorp.gpg
The Signed-By line identifies the dedicated keyring that may also need cleanup after the source is removed.
$ sudo cp /etc/apt/sources.list.d/examplecorp.sources /root/examplecorp.sources.backup
A backup makes it easy to restore the exact repository definition if the wrong source is removed.
$ sudo rm /etc/apt/sources.list.d/examplecorp.sources
Remove only the matching repository file. Do not delete the main Debian source file or unrelated vendor entries.
$ grep -R --line-number --fixed-strings "packages.example.net" /etc/apt/sources.list.d/
No output means the repository URI is no longer present in the active source directory.
$ grep -R --line-number --fixed-strings "/etc/apt/keyrings/examplecorp.gpg" /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null $ sudo rm /etc/apt/keyrings/examplecorp.gpg
Skip the removal when another source file still references the same keyring.
$ sudo apt update Get:1 http://deb.debian.org/debian stable InRelease [140 kB] Get:2 http://deb.debian.org/debian stable-updates InRelease [47.3 kB] Get:3 http://deb.debian.org/debian-security stable-security InRelease [43.4 kB] ##### snipped ##### Reading package lists... Done
The removed repository should not appear in the update output, and the remaining Debian repositories should update without signature or release-file errors.
$ apt-cache policy example-agent
example-agent:
Installed: 2.4.1-1
Candidate: 2.4.1-1
Version table:
*** 2.4.1-1 100
100 /var/lib/dpkg/status
A package can remain installed after its repository is removed. Decide separately whether to keep, replace, downgrade, or purge that package.