Hallo, Entdecker! An dieser Seite wird aktiv gearbeitet, oder sie wird noch übersetzt. Die neuesten und genauesten Informationen findest Du in unserer englischsprachigen Dokumentation.

Deleting and restoring a package

Learn how to delete or restore a package.

GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 2.22, GitHub One, and GitHub AE.


GitHub Packages ist nicht verfügbar für private Repositorys im Besitz von Konten mit älteren Pro-Repository-Plänen. GitHub Packages ist verfügbar mit GitHub Free, GitHub Pro, GitHub Free für Organisationen, GitHub Team, GitHub Enterprise Cloud, und GitHub One. For more information, see "[GitHub's products](/articles/github-s-products)."

Inhalt dieses Artikels

Package deletion and restoration support on GitHub

On GitHub if you have the required access, you can delete:

  • an entire private package
  • an entire public package, if there's not more than 25 downloads of any version of the package
  • a specific version of a private package
  • a specific version of a public package, if the package version doesn't have more than 25 downloads

Hinweis:

  • You cannot delete a public package if any version of the package has more than 25 downloads. In this scenario, contact GitHub support for further assistance.
  • When deleting public packages, be aware that you may break projects that depend on your package.

On GitHub, you can also restore an entire package or package version, if:

  • You restore the package within 30 days of its deletion.
  • The same package namespace is still available and not used for a new package.

Packages API support

You can use the REST API to manage your packages. For more information, see the "GitHub Packages API."

For packages that inherit their permissions and access from repositories, you can use GraphQL to delete a specific package version. The GitHub Packages GraphQL API does not support containers or Docker images that use the package namespace https://ghcr.io/OWNER/PACKAGE-NAME. For more information about GraphQL support, see "Deleting a version of a repository-scoped package with GraphQL."

Note: GitHub Container Registry is currently in public beta and subject to change. During the beta, storage and bandwidth are free. To use GitHub Container Registry, you must enable the feature preview. For more information, see "About GitHub Container Registry" and "Enabling improved container support."

Required permissions to delete or restore a package

For packages that inherit their access permissions from repositories, you can delete a package if you have admin permissions to the repository.

Repository-scoped packages on GitHub Packages include these packages:

  • npm
  • RubyGems
  • maven
  • Gradle
  • NuGet
  • Docker images at docker.pkg.github.com/OWNER/REPOSITORY/IMAGE-NAME

To delete a package that has granular permissions separate from a repository, such as containers or Docker images stored at https://ghcr.io/OWNER/PACKAGE-NAME, you must have admin access to the package.

Note: GitHub Container Registry is currently in public beta and subject to change. During the beta, storage and bandwidth are free. To use GitHub Container Registry, you must enable the feature preview. For more information, see "About GitHub Container Registry" and "Enabling improved container support."

Automate package version deletion with GitHub Actions

You can automate package version deletion using an official action created by GitHub. This action is available in the actions repository or on GitHub Marketplace and only works with repository-scoped packages. For more information, see the "Delete Package Versions" action on GitHub Marketplace or in the actions repository.

Deleting a package version

Deleting a version of a repository-scoped package on GitHub

To delete a version of a repository-scoped package, you must have admin permissions to the repository that owns the package. For more information, see "Required permissions."

  1. Navigiere in GitHub zur Hauptseite des Repository.

  2. To the right of the list of files, click Packages.

    Link „Packages" (Pakete) auf der Übersichtsseite

  3. Search for and select your package.

  4. In the top right of your package's landing page, click Package settings.

    Package settings button

  5. On the left, click Manage versions.

  6. To the right of the version you want to delete, click and select Delete version.

    Delete package version button

  7. To confirm deletion, type the package name and click I understand the consequences, delete this version.

    Confirm package deletion button

Deleting a version of a repository-scoped package with GraphQL

For packages that inherit their permissions and access from repositories, you can use the GraphQL to delete a specific package version.

GraphQL is not supported for containers or Docker images at ghcr.io. Use the deletePackageVersion mutation in the GraphQL API. You must use a token with the read:packages, delete:packages, and repo scopes. For more information about tokens, see "About GitHub Packages."

The following example demonstrates how to delete a package version, using a packageVersionId of MDIyOlJlZ2lzdHJ5UGFja2FnZVZlcnNpb243MTExNg.

curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer TOKEN" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"MDIyOlJlZ2lzdHJ5UGFja2FnZVZlcnNpb243MTExNg==\"}) { success }}"}' \
HOSTNAME/graphql

To find all of the private packages you have published to GitHub Packages, along with the version IDs for the packages, you can use the registryPackagesForQuery connection. You will need a token with the read:packages and repo scopes. You will need a token with the read:packages and repo scopes.

For more information about the deletePackageVersion mutation, see "deletePackageVersion."

You cannot directly delete an entire package using GraphQL, but if you delete every version of a package, the package will no longer show on GitHub.

Deleting a version of a user-scoped package on GitHub

To delete a specific version of a user-scoped package on GitHub, such as for a Docker image at ghcr.io, use these steps. To delete an entire package, see "Deleting an entire user-scoped package on GitHub."

Note: GitHub Container Registry is currently in public beta and subject to change. During the beta, storage and bandwidth are free. To use GitHub Container Registry, you must enable the feature preview. For more information, see "About GitHub Container Registry" and "Enabling improved container support."

To review who can delete a package version, see "Required permissions."

  1. On GitHub, navigate to the main page of your user account.
  2. In der oberen rechten Ecke von GitHub klicke auf Dein Profilfoto und dann auf your profile (Dein Profil).
    Profilfoto
  3. On your profile page, in the top right, click Packages.
    Packages option on profile page
  4. Search for and select your package.
  5. In the top right of your package's landing page, click Package settings.
    Package settings button
  6. On the left, click Manage versions.
  7. To the right of the version you want to delete, click and select Delete version.
    Delete package version button
  8. To confirm deletion, type the package name and click I understand the consequences, delete this version.
    Confirm package deletion button

Deleting a version of an organization-scoped package on GitHub

To delete a specific version of an organization-scoped package on GitHub, such as for a Docker image at ghcr.io, use these steps. To delete an entire package, see "Deleting an entire organization-scoped package on GitHub."

Note: GitHub Container Registry is currently in public beta and subject to change. During the beta, storage and bandwidth are free. To use GitHub Container Registry, you must enable the feature preview. For more information, see "About GitHub Container Registry" and "Enabling improved container support."

To review who can delete a package version, see "Required permissions."

  1. On GitHub, navigate to the main page of your organization.
  2. Under your organization name, click Packages.
    Container access invite button
  3. Search for and select your package.
  4. In the top right of your package's landing page, click Package settings.
    Package settings button
  5. On the left, click Manage versions.
  6. To the right of the version you want to delete, click and select Delete version.
    Delete package version button
  7. To confirm deletion, type the package name and click I understand the consequences, delete this version.
    Confirm package version deletion button

Deleting an entire package

Deleting an entire repository-scoped package on GitHub

To delete an entire repository-scoped package, you must have admin permissions to the repository that owns the package. For more information, see "Required permissions."

  1. Navigiere in GitHub zur Hauptseite des Repository.

  2. To the right of the list of files, click Packages.

    Link „Packages" (Pakete) auf der Übersichtsseite

  3. Search for and select your package.

  4. In the top right of your package's landing page, click Package settings.

    Package settings button

  5. Under "Danger Zone", click Delete this package.

  6. To confirm, review the confirmation message, enter your package name, and click I understand, delete this package.

    Confirm package deletion button

Deleting an entire user-scoped package on GitHub

To review who can delete a package, see "Required permissions."

  1. On GitHub, navigate to the main page of your user account.
  2. In der oberen rechten Ecke von GitHub klicke auf Dein Profilfoto und dann auf your profile (Dein Profil).
    Profilfoto
  3. On your profile page, in the top right, click Packages.
    Packages option on profile page
  4. Search for and select your package.
  5. In the top right of your package's landing page, click Package settings.
    Package settings button
  6. On the left, click Options.
    "Options" menu option
  7. Under "Danger zone", click Delete this package.
    Delete package version button
  8. To confirm deletion, type the package name and click I understand the consequences, delete this package.
    Confirm package version deletion button

Deleting an entire organization-scoped package on GitHub

To review who can delete a package, see "Required permissions."

  1. On GitHub, navigate to the main page of your organization.
  2. Under your organization name, click Packages.
    Container access invite button
  3. Search for and select your package.
  4. In the top right of your package's landing page, click Package settings.
    Package settings button
  5. On the left, click Options.
    "Options" menu option
  6. Under "Danger zone", click Delete this package.
    Delete package button
  7. To confirm deletion, type the package name and click I understand the consequences, delete this package.
    Confirm package deletion button

Restoring packages

You can restore a deleted package or version if:

  • You restore the package within 30 days of its deletion.
  • The same package namespace and version is still available and not reused for a new package.

For example, if you have a deleted rubygem package named octo-package that was scoped to the repo octo-repo-owner/octo-repo, then you can only restore the package if the package namespace rubygem.pkg.github.com/octo-repo-owner/octo-repo/octo-package is still available, and 30 days have not yet passed.

You must also meet one of these permission requirements:

  • For repository-scoped packages: You have admin permissions to the repository that owns the deleted package.
  • For user-account scoped packages: Your user account owns the deleted package.
  • For organization-scoped packages: You have admin permissions to the deleted package in the organization that owns the package.

For more information, see "Required permissions."

Once the package is restored, the package will use the same namespace it did before. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.

Restoring a package in an organization

You can restore a deleted package through your organization account settings, as long as the package was in one of your repositories or had granular permissions and was scoped to your organization account.

To review who can restore a package in an organization, see "Required permissions."

  1. Navigiere auf GitHub zur Hauptseite der Organisation.
  2. Klicke unter Deinem Organisationsnamen auf Settings (Einstellungen).
    Schaltfläche „Organization settings" (Organsationseinstellungen)
  3. On the left, click Packages.
  4. Under "Deleted Packages", next to the package you want to restore, click Restore.
    Schaltfläche „Restore" (Wiederherstellen)
  5. To confirm, type the name of the package and click I understand the consequences, restore this package.
    Restore package confirmation button

Restoring a user-account scoped package

You can restore a deleted package through your user account settings, if the package was in one of your repositories or scoped to your user account. For more information, see "Required permissions."

  1. Klicke in der oberen rechten Ecke einer beliebigen Seite auf Dein Profilfoto und klicke dann auf Settings (Einstellungen).
    Symbol „Settings" (Einstellungen) auf der Benutzerleiste
  2. On the left, click Packages.
  3. Under "Deleted Packages", next to the package you want to restore, click Restore.
    Schaltfläche „Restore" (Wiederherstellen)
  4. To confirm, type the name of the package and click I understand the consequences, restore this package.
    Restore package confirmation button

Restoring a package version

You can restore a package version from your package's landing page. To review who can restore a package, see "Required permissions."

  1. Navigate to your package's landing page.
  2. On the right, click Package settings.
  3. On the left, click Manage versions.
  4. On the top right, use the "Versions" drop-down menu and select Deleted.
    Versions drop-down menu showing the deleted option
  5. Next to the deleted package version you want to restore, click Restore.
    Restore option next to a deleted package version
  6. To confirm, click I understand the consequences, restore this version.
    Confirm package version restoration

Did this doc help you?

Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Oder, learn how to contribute.