Sometimes you need to move a repository to a machine that cannot reach your Git server, or you want one file to drop into a backup. git bundle does that.
git bundle create backup.bundle --all
--all packs every ref: branches, tags, the lot. The result is a single file you can copy onto a USB stick or into a backup folder. Check it before you trust it:
git bundle verify backup.bundle
That checks that the bundle is valid and will apply cleanly, and exits with zero when it is fine. On the other side, a bundle acts like a read-only remote:
git clone backup.bundle myproject
You can also make a bundle of just a range of commits, for example only what is new since the last transfer. The catch, according to the docs, is that the other side then needs the commits the range is based on. A bundle made with --all is self-contained, so that is what I’d use for backups.
Caveat: a bundle holds commits and refs, nothing else. The docs list what is left out: the index, the working tree, the stash, the repository’s own config and its hooks. Uncommitted work is not in it, so commit or stash it somewhere else first.
Further reading: git-bundle documentation, On this site: git bundle's cousin, git archive