brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git bundle puts a whole repository in one file you can clone from

Git
~/tips/tip-git-bundle-offline-backup

git bundle create backup.bundle --all

Packs all branches and tags of a repo into one file for offline transfer or backup.

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

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link