I’m just starting to use git for version control. I’d like to keep a backup copy of my repository on a local fileserver. After reading about the right way to backup a git repository, I decided to store the repository as a git bundle on the fileserver.
I can bundle my repository and copy the resulting bundle to the fileserver. Check. I also tried cloning and pulling from it. Everything working well. However, I’d like to push my local changes from time to time as well. When I execute something like
git push bundlefile.git
I get the error:
error: failed to push some refs to 'bundlefile.git'
You can clone or pull from a bundle, but is it not possible to push to it? I don’t really want to create a bundle of my whole repository every time I want to back up.
Is this user error or are bundles not intended to be pushed to?
You cannot push directly to a bundle file. A bundle file is a compressed representation of a repository, and to modify it would involve unbundling, pushing, and bundling again.
One way to do this is as you said, create a new bundle every time you want to make a backup.
Another way is to create a bare repository on the file server, and push to that. A bare repository is a repository without a working directory, which is essentially the contents of the
.gitdirectory from a normal clone. You can create a bare repository withgit init --bare.