13

This issue is not the same as this or this.

git svn clone -s --bare https://ctags.svn.sourceforge.net/svnroot/ctags
Unknown option: bare

What is wrong?

Can I use git svn to clone a bare repo?

I have read man git-svn, and cannot find a method to clone a bare repo.

Edit 1

My tags on git svn repo:

git branch -r
  origin/master
  tags/Ctags-5_1
  tags/Ctags-5_1_1
  tags/Ctags-5_2
  tags/Ctags-5_2_1
  tags/Ctags-5_2_2
  tags/Ctags-5_2_3
  tags/Ctags-5_3
  tags/Ctags-5_3_1
  tags/Ctags-5_4
  tags/Ctags-5_5
  tags/Ctags-5_5_1
  tags/Ctags-5_5_2
  tags/Ctags-5_5_3
  tags/Ctags-5_5_4
  tags/Ctags-5_6
  tags/ctags-5.7
  tags/ctags-5.8
  tags/test
  trunk

Why I cannot push these tags into the git repository?

Community
  • 1
  • 1
hugemeow
  • 7,777
  • 13
  • 50
  • 63

2 Answers2

16

Found a better solution

$ git svn init https://ctags.svn.sourceforge.net/svnroot/ctags repo-git --stdlayout 
$ #edit  repo-git/.git/config to contain:
[svn-remote "svn"]
        url = https://ctags.svn.sourceforge.net/svnroot/ctags
        fetch = trunk:refs/heads/master
        branches = branches/*:refs/heads/*
        tags = tags/*:refs/tags/*
$ cd repo-git
$ git svn fetch

After all you may set core.bare=true. The resulting bare repository will be in repo/.git

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • why i should change remotes to heads? and why tags = tags/*:refs/tags/* is not tags = tags/*:refs/heads/tags/* ? – hugemeow Sep 26 '12 at 17:08
  • Because by definition Git tag is a reference in refs/tags/* namespace. If you run "git tag -l" (list all tags), Git will actually list all refs/tags/* reference. As I think this is what you want. Actually I don't understand your ultimate goal (one-time migration and forgetting about Subversion or working with Subversion using Git locally). If you want just migration, this option is what you need. – Dmitry Pavlenko Sep 26 '12 at 19:50
  • 1
    Just to add a work note. Many a times, we like to maintain the link with svn repository intact. I found creating two repositories helpful. One repository to maintain git-svn (this should be non-bare). The other bare repository would serve as a server for all git child repositories. The git-svn repository acts as merge-pot for both git and svn servers. – Yogesh Sajanikar May 15 '15 at 05:53
14

git-svn is a Perl script, if you open it, you can realize that it doesn't contain word "bare" at all. Option "--bare" is not supported.

As a workaround you can use simple "git svn clone" and then convert the resulting repository to bare.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • 1
    no, you should juts update all refs/heads/* to corresponding refs/remotes/* values – Dmitry Pavlenko Sep 23 '12 at 11:30
  • i use git svn clone -s to clone all branches, but when i push this repo to remote git repo, all branches are lost, why, how to update all refs/heads/* to corresponding refs/remotes/* ? – hugemeow Sep 23 '12 at 12:33
  • with a script: for each branch run "git update-ref refs/heads/branch refs/remotes/branch" – Dmitry Pavlenko Sep 23 '12 at 13:05
  • in fact there is only one branch, but with many tags, how to push tags to remote git repo? just cannot do it using git pull --tag, read edit 1, plz – hugemeow Sep 23 '12 at 16:26
  • I'm a bit confused: you want to push or pull? and to/from remote Git or remote SVN (as I understand you work with remote SVN repository). To push a tag to git run "git push origin tagname". To push a tag to SVN git-svn won't help. I know 2 solutions to push tag from Git to SVN: SubGit and SmartGit and only SmartGit works with a remote repository. – Dmitry Pavlenko Sep 23 '12 at 18:15
  • svn repo is the original repo, now i want to create git repo from svn repo, and push all changes from svn repo to git repo, the issue is i cannot push the branches and tags from svn repo to git repo... – hugemeow Sep 24 '12 at 20:34
  • 1
    Have a look at my another "better solution". The line "tags = tags/*:refs/tags/*" will make sure that SVN tags will be converted to Git tags. Otherwise you can do that manually by running "git update-ref refs/tags/tagname refs/remotes/tags/tagname" for every tagname (Ctags-5_1, Ctags-5_1_1, ...) – Dmitry Pavlenko Sep 24 '12 at 21:20
  • "git update-ref refs/tags/tagname refs/remotes/tags/tagname" for every tagname will be nightmare since there maybe thousands of tags there, even write a script is not nice, "tags = tags/*:refs/tags/*" what is that? git svn clone first, then modify .git/config file? – hugemeow Sep 24 '12 at 21:24
  • 1
    First "git svn init ..." then modify .git/config, then "git svn fetch" as I wrote. Yes git-svn is nightmare, I agree :) – Dmitry Pavlenko Sep 24 '12 at 21:29