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 repositori
Instead of cloning from the bundle, create a new repository and fetch using a wildcard refspec. I have added a second branch feature
and a tag v1.0
to the example to make this more illustrative:
$ mkdir there
$ git init .
$ git fetch --update-head-ok ../here/myrepo.bundle '*:*'
Receiving objects: 100% (5/5), done.
From ../here/myrepo.bundle
* [new tag] v1.0 -> v1.0
* [new branch] master -> master
* [new branch] feature -> feature
$ git checkout
The *:*
refspec will fetch all remote refs into equally named local refs, creating them if they don't exist. The --update-head-ok
argument is needed since git init
will create a master
branch which is likely also present in the remote.
Since this is a fetch with a direct URL, no remotes are needed at all. Note that this would work equally for any kind of source repo URL, not just for bundles.
The equality of the refs of the old and new repository can be checked by comparing the output of git show-ref
in both repositories, they should be identical.