so, rather than a normal git clone, do:
git clone --mirror git@example.org:path/repo.git
replacing the example url with the real git repo in question.
and rather than a tar/gz/zipball, do:
git bundle create repo.bundle --all
in the root of the git repo.
This creates a large file, repo.bundle (you can change the name), containing the entire archive source, all branches, and all commits. The only things it is missing, are remotes, forks - and if it's github or gitlab, PRs/MRs, Wikis, and Issue Reports and other metadata would need to be backed up separately.
This only backs up the repository contents, itself.
To unbundle it locally, just do a
git clone repo.bundle
and it'll produce a full git directory from your bundle.
(The bundle now becomes your remote.)
See also: https://wiki.archiveteam.org/index.php/GitHub#Backup_tools for tools specifically for github archival.

