Unarchive a GitHub Repository Safely with gh
A repository someone archived months ago suddenly needs a fix. gh repo unarchive brings it back with one command and no local checkout changes, plus a check that confirms it actually happened. Allow five to ten minutes.
The route
Jump straight to the step you need, or tick off Done means at the end.
- You need: GitHub CLI, an authenticated account with permission to administer the repository, and either a local checkout that identifies the target or its full
OWNER/REPOSITORYname.
This changes repository state on GitHub. It does not change files in your checkout, and it does not require root or sudo. 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.
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, 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 whenever there is any chance 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
isArchived=true 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 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, inspect what gh resolves first:
$ gh repo view --json nameWithOwner,isArchived --jq '.nameWithOwner + " archived=" + (.isArchived | tostring)'
OWNER/REPOSITORY archived=true
Only use the no-argument form once that output matches the repository you meant to change.
3. Confirm the change before making it
Unarchiving is a remote state change that can affect whether people can work with the repository again, so pause here if it is subject to a retention, release or incident process. Make sure the repository name in the checkpoint above is exact.
For an interactive run, let gh show its confirmation prompt:
$ gh repo unarchive "$REPOSITORY"
Type y only when the displayed target is correct. The exact prompt wording and 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
Warning
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 the wrong repository was selected, stop trusting 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 command is gh repo archive, which also has a confirmation prompt and a --yes option:
$ gh repo archive "$REPOSITORY"
? Archive OWNER/REPOSITORY? (y/N)
Safety boundary
Archiving is a separate destructive or service-disrupting decision. Do not run it as an automatic reaction to an unexpected result, and only if you are authorised to restore the previous archived state. 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 ran 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.