I'm not sure why this isn't really covered simply in one place but here it goes...
Using just the cli you can do the following
a `git archive` command is not the thing we want, that is more for prepping code for deployment to a site…
more like https://docs.github.com/en/repositories/archiving-a-github-repository/backing-up-a-repository we want to offline or backup the repo
The idea is:
`git clone --mirror <repository_url>` which results in a dir `<repository_url>.git/`
`cd <repository_url>.git/`
`git bundle create ../<repository_name>.bundle --all` which makes a single file which can be cloned from later
compress it as you like `zstd --compress --progress --threads=0 --rm <repository_name>.bundle`
Then to get it all back you reverse the process
decompress the file `zstd --decompress --progress --threads=0 --rm <repository_name>.bundle.zst`
`git clone /path/to/<repository_name>.bundle /path/to/restored_repo`
and that should be it…
In practice, when I do this all the branches are remote still
```
master
* newfeature
remotes/origin/20190108-release
remotes/origin/20220509-release
remotes/origin/406-thing
```
but the remote is actually the bundle
```
ivan@srv:/ssd/git_repo_restored$ git remote -v
origin /ssd/git_rep.bundle (fetch)
origin /ssd/git_rep.bundle (push)
```