← Back to all guides
Guide

Back Up GitHub Repositories: The Clone Step Nobody Does

Updated Nov 14, 2026

GitHub has an export feature. It produces a JSON file listing your repositories, your issues, your stars, your organisations. It is useful metadata, and it is not a backup. The thing almost nobody does is the part that actually preserves the code, and it is one command in a terminal.

Export at a glance

Request method
In-product settings
Delivery time
Instant (seconds)
Archive format
JSON
Sensitivity
High: health, biometric, financial, precise location
Primary use
Backup: preserve a copy for yourself

Archive file map

Top-level structure of the export. Each entry is a file or directory with its format badge and what it contains.

repositories.jsonJSON
List of your repositories: name, owner, public/private, language, description
issues.jsonJSON
Summary of your issues across repositories. Not the full comment threads.
pull_requests.jsonJSON
Summary of your pull requests. Not the full review discussions.
activity_log.jsonJSON
Timestamped log of everything you have done on GitHub, going back to account creation

What the GitHub data request actually gives you

Go to Settings, then Account, and you will find an "Export account data" link near the bottom. Click it, and GitHub emails you a ZIP file, usually within an hour. Inside is a directory of JSON files: a list of your repositories, your issues, your pull requests, your comments, your organisations, your followers, and a long activity log going back to the day you created your account.

What is not in that ZIP is your code. The repository list tells you what repositories exist, whether they are public, and what language they are in. It does not contain a single line of source. If your GitHub account disappeared tomorrow, a JSON file listing your repositories is not much use to you.

The export is metadata. It describes what you have. It is not the thing itself.

The clone step almost everybody skips

A real backup means cloning every repository you care about. Not a zip of your account, not a screenshot of your dashboard, but an actual git clone of the source code, pushed somewhere you own.

The command is straightforward:

  1. Open a terminal on a machine with git installed.
  2. For each repository you want to back up, run: git clone --mirror git@github.com:username/repository.git
  3. The --mirror flag is important. A normal clone gives you the default branch and a working directory. A mirror clone gives you every branch, every tag, every ref, and the complete history. For a backup, that is the one you want.
  4. Copy the resulting .git directory to somewhere you own: an external drive, a NAS, a second Git hosting provider. A repository is not backed up until it exists in two places.

Why --mirror and not a normal clone

A normal git clone checks out the default branch and gives you a working directory. It is what you want for development. It is not what you want for a backup, because it does not include every branch or every tag.

A mirror clone is a bare repository containing every ref. When you restore from it, you get the complete history, including branches you forgot existed and tags you created three years ago and never looked at again. That is the difference between a backup and a partial copy.

If you have branches you have not pushed, they are not in the mirror. Push them first.

LFS objects are a separate problem

If your repository uses Git LFS for large files, the mirror clone does not pull them by default. The .gitattributes file is there, the pointers are there, but the actual large files are not.

After the mirror clone, run: git lfs fetch --all

That pulls every LFS object. Without it, your backup contains references to large files but not the files themselves, which is a backup that does not work when you need it.

Private repositories and authentication

Public repositories clone without authentication. Private repositories require it, and that is where scheduled backups get complicated.

The simplest route is an SSH key with no passphrase, stored on the machine running the backup. That is not ideal from a security perspective, but it is what makes an unattended nightly cron job work. A passphrase-protected key requires manual intervention, which means the backup stops happening.

The other route is a personal access token with repo scope, used over HTTPS. The token goes in the clone URL: git clone https://TOKEN@github.com/username/repository.git. Tokens expire, so a token-based backup needs a rotation plan or it stops working without warning.

Either way, test the authentication before you trust the schedule. A backup that has never run successfully is not a backup.

The things that are not in any repository

A repository is code and history. GitHub stores other things separately, and they need their own export path.

  • Gists: snippets hosted at gist.github.com, separate from any repository. An anonymous gist disappears with your account, and a git clone of your repositories does not include it. Export gists separately, or push them to a real repository.
  • Wikis: each repository can have a wiki, stored as a separate git repository at repository.wiki.git. Clone it with git clone --mirror git@github.com:username/repository.wiki.git if you want it.
  • Issues and pull requests: the account export gives you a summary, not the full comment threads. If the discussion matters, export it separately or write it down somewhere durable.
  • GitHub Actions artifacts: the files your workflows produce. They expire after a set number of days and are not in any backup. If an artifact matters, download it or push it somewhere.
  • Workflow run logs: the output of each workflow run. GitHub keeps them for a limited time, and they are not in any export.
  • Pages deploy history: which commits were deployed, when, and to what URL. Not in the account export, not in the repository.
  • Repository secrets: the encrypted values your workflows use. GitHub does not export them, ever. If you lose them, you re-create them from memory or from whatever documentation existed.

Before you delete a repository or leave an organisation

Deleting a repository is permanent. There is no recovery window, no trash bin, no "are you sure" that can be undone. Once it is gone, the code, the issues, the pull requests, the wiki, the actions history, all of it is gone.

If you are leaving an organisation, the repositories you have access to today are not yours tomorrow. The organisation owner can remove your access at any point, and there is no export button on the other side of that decision.

Clone what matters before the decision becomes irreversible. A mirror clone of every repository you care about, pushed somewhere you control, is the difference between a clean exit and a loss you cannot recover from.

Storing the backup

A repository is not backed up until it exists in two places. A mirror clone on your laptop is a copy, not a backup. A copy on an external drive is better. A copy on a drive and a copy on a second hosting provider is the whole difference between an archive and a single point of failure.

Name the directory with the date, something like github-backup-2026-11. Keep the .git directories intact; they are the repository. Do not zip them unless you are archiving for long-term storage, and if you do, keep the ZIP in the same rotation as the rest of your backups.

Test the restore. A backup you have never restored from is a backup you are not sure works. Clone from your mirror to a temporary directory and confirm the history is complete.

Quick version

If you want the short checklist instead of the full guide, use the service page.

Related guides

FAQ

Does the GitHub data export contain my code?

No. The export is a JSON file describing your account: repositories, issues, stars, organisations, followers, gists. It does not contain source code. A real backup means cloning every repository yourself.

What is the difference between git clone and git clone --mirror?

A normal clone checks out the default branch and gives you a working directory. A mirror clone gives you every branch, every tag, every ref, and the complete history. For a backup, the mirror is the one you want.

Does git clone --mirror include LFS files?

No. The mirror clone includes the LFS pointers but not the actual large files. After the mirror, run git lfs fetch --all to pull the LFS objects.

How do I back up private repositories?

Private repositories require authentication. Use an SSH key with no passphrase for unattended backups, or a personal access token over HTTPS. Test the authentication before you trust the schedule.

Are gists included in a repository clone?

No. Gists are separate from repositories. An anonymous gist disappears with your account. Export gists separately or push them to a real repository.

What happens when I delete a repository?

Deletion is permanent. There is no recovery window. The code, issues, pull requests, wiki, and actions history are all gone. Clone what matters before the decision becomes irreversible.

Are GitHub Actions artifacts in any export?

No. Artifacts expire after a set number of days and are not in any backup. If an artifact matters, download it or push it somewhere durable.

Can I export my GitHub Issues with full comment threads?

The account export gives you a summary, not the full threads. If the discussion matters, export it separately using the GitHub API or a third-party tool.

Last verified: Nov 14, 2026. Steps checked against github.com. Report an outdated step →

About the author

Charles runs Digital Takeout Day, a twice-yearly reminder (May 8 and November 8) to download and back up your data from every online service you use.

Every guide is cross-checked against the platform's own export documentation and re-verified before each Takeout Day.

Read the full bio, editorial policy, and contact →