I would like to create a backup of a git repository that I use for tracking a svn repository (with git-svn). Can I use git push --mirror for that purpose or would I lose any git-svn related information when I needed to restore the backup?
It is possible git push
or git bundle
do not include svn metadata.
But according to git svn
intro, you could then try and restore those svn metadata.
(disclaimer: not tested directly)
Rebuilding git-svn metadata
If you copied the repository from somewhere else (eg, from repo.utsl.gen.nz
) via git-clone
, or if you just blew it away, then you won't have any SVN metadata - just commits.
In that case, you need to rebuild your SVN metadata, for instance, for just keeping trunk up to date - git-svn
will rebuild its metadata when you run git-svn fetch
.
$ git update-ref refs/remotes/trunk origin/svn/trunk
$ git svn init https://svn.perl.org/parrot/trunk
Using higher level of URL: https://svn.perl.org/parrot/trunk => https://svn.perl.org/parrot
$ git svn fetch
Rebuilding .git/svn/git-svn/.rev_db.d31e2699-5ff4-0310-a27c-f18f2fbe73fe ...
r17220 = 78ad11bf2f61b35e1cb32a978ab546d198be8a2e
r17219 = 605264b06d84670ec402d7a7a21c0016cae3a928
r17218 = a8ceba9c503d2be8e8e69a3df454017322906cf5
...
The key thing to remember with rebuilding
git-svn
metadata is to make the refs look just like they would look from a fresh import; you can do this usinggit update-ref
as above, by copying refs files around inside.git/refs/
, or usinggit pack-refs
then editing.git/packed-refs
.
To test that you got it right, usegit show-ref
- perhaps compare with a fresh SVNHEAD
clone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With