Unarchive a GitHub Repository Safely with gh
You will finish with a GitHub repository restored from archived status, and a check that confirms the change. The command is gh repo unarchive, from GitHub CLI. On this machine, gh version reports 2.87.3. The local Debian package database reports package gh version 2.45.0-1ubuntu0.3+esm3, so check the executable version rather than assuming the package metadata describes the binary on your PATH.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow five to ten minutes. You need GitHub CLI, an authenticated account with permission to administer the repository, and either a local checkout that identifies the target repository or its full OWNER/REPOSITORY name. This changes repository state on GitHub. It does not change files in your checkout, and it does not require root or sudo.
1. Check the installed command
Read the command's local contract before using it:
$ gh repo unarchive --help
Unarchive a GitHub repository.
With no argument, unarchives the current repository.
USAGE
gh repo unarchive [<repository>] [flags]
FLAGS
-y, --yes Skip the confirmation prompt
The only option is --yes, also written -y. Without it, gh asks for confirmation. That prompt is a useful guard against an accidental target, so leave it enabled for a first run.
Checkpoint: confirm which executable will run and record its version:
$ command -v gh
/usr/bin/gh
$ gh version
gh version 2.87.3 (2026-02-23)
Your path and version may differ. The syntax in this guide comes from the installed help and the local gh-repo-unarchive(1) manpage.
2. Choose and inspect the repository
Use the full repository name when there is any chance that the current directory points at a different remote. Replace the obvious placeholders with the real owner and repository:
$ REPOSITORY='OWNER/REPOSITORY'
$ gh repo view "$REPOSITORY" --json nameWithOwner,isArchived --jq '.nameWithOwner + " archived=" + (.isArchived | tostring)'
OWNER/REPOSITORY archived=true
The isArchived=true result is the checkpoint you want before changing state. If it is false, stop: the repository is already active, and unarchive is unnecessary. If gh reports that the repository cannot be found, check spelling, host selection, authentication and your administration permission before retrying.
Do not rely on a repository name copied from an issue, chat message or shell history without checking it. A similar name can identify a different owner or project. If you intend to use the current checkout instead, first inspect what gh resolves:
$ gh repo view --json nameWithOwner,isArchived --jq '.nameWithOwner + " archived=" + (.isArchived | tostring)'
OWNER/REPOSITORY archived=true
Only use the no-argument form after that output matches the repository you meant to change.
3. Confirm the change before making it
Unarchiving is a remote state change. It can affect whether people can work with the repository again, so pause here if the repository is subject to a retention, release or incident process. Make sure the repository name in the checkpoint is exact.
For an interactive run, let gh show its confirmation prompt:
$ gh repo unarchive "$REPOSITORY"
When gh asks for confirmation, type y only when the displayed target is correct. The exact prompt wording and command output can vary by gh version. Any response other than confirmation should leave the repository unchanged. This is an ordinary user command, not an elevated operation.
For a reviewed script or a run where the target has already been checked in the same script, --yes skips the prompt:
$ gh repo unarchive "$REPOSITORY" --yes
Use --yes only when $REPOSITORY is a controlled value. Do not combine it with an unquoted variable or a value pasted from an untrusted source. The option removes an interactive safety check; it does not grant permission.
4. Verify the repository is active
Do not treat a quiet shell prompt as proof. Query the repository again:
$ gh repo view "$REPOSITORY" --json nameWithOwner,isArchived --jq '.nameWithOwner + " archived=" + (.isArchived | tostring)'
OWNER/REPOSITORY archived=false
The useful result is archived=false. The command's exit status also matters: a non-zero status means the request or verification failed. If the first command returned an error, rerun the read-only view command and resolve that error before trying to unarchive again.
5. Recover from a wrong or failed run
If you notice that the wrong repository was selected, stop using the shell history as a guide and inspect the exact owner and name with gh repo view. If the repository has already been unarchived, there is no local rollback involved because the change happened on GitHub, not in the checkout.
The matching gh command is gh repo archive, which also has a confirmation prompt and a --yes option. Use it only if you are authorised to restore the previous archived state and have checked the exact target again:
$ gh repo archive "$REPOSITORY"
? Archive OWNER/REPOSITORY? (y/N)
Archiving is a separate destructive or service-disrupting decision. Do not run it as an automatic reaction to an unexpected result. If the repository belongs to a team, record the incident and let the owner decide whether it should be archived again.
Done means
- The installed executable and its version were checked.
- The full repository name was inspected before any state change.
- The command was run interactively, or
--yeswas used only after an equivalent explicit check. - A second
gh repo viewquery reportsarchived=false. - No root privileges, checkout edits or unreviewed repository selection were involved.