Is there a way to create a backup using git bundle where there is no linkage to the bundle file after cloning from the backup? I'd like to backup my repositories to a single file with all history and restore them, exactly, later.
At the moment, I'm creating a backup using the following methodology:
$ mkdir here $ cd here $ git init Initialized empty Git repository in /tmp/here/.git/ $ touch stuff $ git add stuff $ git commit -m "This is a file" [master (root-commit) c867bcf] This is a file 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 stuff $ git bundle create myrepo.bundle --all Counting objects: 3, done. Writing objects: 100% (3/3), 212 bytes | 212.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) Alright, so at this point we have a bundle with a simple repository. Now, when we try to copy this repository from the bundle:
$ cd .. $ mkdir there $ cd there /tmp/there $ git clone ../here/myrepo.bundle . Cloning into '.'... Receiving objects: 100% (3/3), done. /tmp/there $ git remote -v origin→ /tmp/there/../here/myrepo.bundle (fetch) origin→ /tmp/there/../here/myrepo.bundle (push) This shows that we have a link to the original bundle files, which I don't want. I also tried to create a mirror, but the problem remains the same:
$ cd .. $ mkdir there $ cd there $ git clone --mirror ../here/myrepo.bundle ./.git Cloning into bare repository './.git'... Receiving objects: 100% (3/3), done. $ git config --bool core.bare false $ git reset --hard HEAD HEAD is now at c867bcf This is a file /tmp/there $ git remote -v origin→ /tmp/there/../here/myrepo.bundle (fetch) origin→ /tmp/there/../here/myrepo.bundle (push) Although we could just copy the entire repository as is to back things up, I really only want to backup a single file that only contains the files currently under revision. I've been backing up the directories and it's been causing a mess with all of the leftover files. As such, I'd really only like to archive a single file, which is why I'm using bundle, and I'd like the recovery from the backup to be clean as in no linkages at all to the bundle file. Thanks for the help.
git remote remove originafter cloning?git bundle) as a backup mechanism. There's nothing inherently wrong with this, they just don't play well together, as you've discovered. You can paper over the "don't play well together" part, or use a real backup system, or whatever other solution you like. Note that the nature of a DVCS is that any one reop, once updated from another, is a superset of (if it has its own commits that the other doesn't), or is equal to, the other repo, so in some sense there's no need to make backups. But only in some sense.:-)git bundleamounts to runninggit fetchorgit pushwithout the other (second) Git around to answer have/want queries, so the git-rev-list-args argument has to provide your best guesses about what they don't have (and hence want). Then the data stream that fetch or push would construct is instead made into a bundle-file. The result is that single file you'd like. You could make an archive of the.gitdirectory with any archiver; that's probably similar enough if you always want everything, i.e., if your rev-list arguments are just--all.