Skip to main content

Esta versión de GitHub Enterprise se discontinuó el 2022-10-12. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener rendimiento mejorado, seguridad mejorada y nuevas características, actualice a la versión más reciente de GitHub Enterprise. Para obtener ayuda con la actualización, póngase en contacto con el soporte técnico de GitHub Enterprise.

Deleting and restoring a package

Learn how to delete or restore a package.

GitHub Packages está disponible con GitHub Free, GitHub Pro, GitHub Free para organizaciones, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 3.0 o superior y GitHub AE. Para obtener más información sobre cómo actualizar la instancia GitHub Enterprise Server, consulta «Acerca de las actualizaciones a nuevas versiones» y el Asistente de mejora para encontrar la ruta de actualización de la versión actual.

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 5000 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 5,000 downloads

Note:

  • You cannot delete a public package if any version of the package has more than 5,000 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

For packages that inherit their permissions and access from repositories, you can use GraphQL to delete a specific package version. For more information about GraphQL support, see "Deleting a version of a repository-scoped package with GraphQL."

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.

The GitHub Packages registries below only use repository-scoped permissions:

  • Docker images at docker.pkg.github.com/OWNER/REPOSITORY/IMAGE-NAME
  • npm
  • RubyGems registry
  • Apache Maven registry
  • NuGet registry

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. En your GitHub Enterprise Server instance, vaya a la página principal del repositorio.
  2. A la derecha de la lista de archivos, haz clic en Versiones. Vínculo a los paquetes en la página de información general del repositorio
  3. Busca y selecciona tu paquete.
  4. En la parte superior derecha de la página de aterrizaje del paquete, haga clic en Package settings (Configuración del paquete). Botón de configuración del paquete
  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.

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 packages connection through the repository object. You will need a token with the read:packages and repo scopes. For more information, see the packages connection or the PackageOwner interface.

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 Enterprise Server.

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. En your GitHub Enterprise Server instance, vaya a la página principal del repositorio.
  2. A la derecha de la lista de archivos, haz clic en Versiones. Vínculo a los paquetes en la página de información general del repositorio
  3. Busca y selecciona tu paquete.
  4. En la parte superior derecha de la página de aterrizaje del paquete, haga clic en Package settings (Configuración del paquete). Botón de configuración del paquete
  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

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 RubyGems 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.

To delete a package, you must also have admin permissions to the repository that owns the deleted 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 a repository owned by the organizaton.

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

  1. En your GitHub Enterprise Server instance, vaya hasta la página principal de la organización.
  2. Debajo del nombre de la organización, haga clic en Settings. Organization settings button
  3. On the left, click Packages.
  4. Under "Deleted Packages", next to the package you want to restore, click Restore. Restore button
  5. 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