Setting Up and Managing Git-Annex with Backblaze B2 Storage
Git-annex is a powerful tool for managing large files in git repositories. This guide will walk you through setting up git-annex with Backblaze B2 as remote storage, and cover common usage scenarios. B2 has a compatible API to AWS S3, offers 10GB free space, and if much cheaper than S3 for larger storage use-cases.
Initial Setup
First, initialize git-annex in your repository:
git annex init
Configuring Backblaze B2 Remote
To set up a Backblaze B2 remote, use the following command:
git annex initremote b2-upload type=S3 \
bucket=your-bucket-name \
embedcreds=no \
encryption=none \
host=s3.us-west-004.backblazeb2.com \
protocol=https \
signature=v4
Note: Git-annex will require your Backblaze B2 credentials. You can provide these through environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
Alternatively, you can use a configuration file for managing multiple credentials.
File Size Configuration
To configure git-annex to only manage files larger than 10MB:
git config annex.largefiles "largerthan=10MB"
Copying Files to Remote
After committing files, copy them to the B2 remote:
git annex copy --to=b2-upload
Setting Up Public Access
To create a public download point:
git annex initremote b2-public type=httpalso --sameas=b2-upload \
url=https://f004.backblazeb2.com/file/your-bucket-name/ encryption=none
Sharing Your Repository
There are two main ways to share your git-annex repository:
1. Direct Transfer Method
- Drop the local copy of the files
- Package and transfer the repository
- At the destination, initialize git-annex
2. GitHub Method
When using GitHub:
- Remember that files in the local repo are symbolic links to the actual files in
.git/annex/objects/
- Git-annex creates a separate
git-annex
branch for configuration - Make sure to push both
main
andgit-annex
branches to GitHub - On the new machine:
- Clone the repository
- Switch to
git-annex
branch - Run
git annex init
- Use
git annex enableremote
command - Get files using
git annex get .
Removing Git-Annex
To remove git-annex from a repository:
- Backup or remove files from
.git/annex/objects/
- Run
git annex uninit
You can verify git configuration settings in .git/config
.
Best Practices
- Always ensure both
main
andgit-annex
branches are pushed when using GitHub - Backup important files before uninitializing git-annex
- Keep track of your B2 credentials securely
This guide covers the basic setup and management of git-annex with Backblaze B2. Remember to replace placeholder values (like your-bucket-name
) with your actual configuration details.
Note: All paths and bucket names in this guide have been anonymized for security purposes.
© 2025 Seyed Yahya Shirazi. All rights reserved.