18

Whilst doing git svn clone -s https://svn.example.com/repo/ I received the following output:

r3073 = a6132f3a937b632015e66d694250da9f606b8333 (refs/remotes/trunk)
Found possible branch point: https://svn.example.com/repo/trunk => https://svn.example.com/repo/branches/v1.3, 3073
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
fatal: Not a valid object name refs/remotes/tags/Sync Controllers
cat-file commit refs/remotes/tags/Sync Controllers: command returned error: 128

Running git branch -a gives:

remotes/tags/Sync%20Controllers
remotes/tags/v1.1
remotes/trunk
remotes/v1.2

I think the problem is that "remotes/tags/Sync Controllers" != "remotes/tags/Sync%20Controllers".

Benjie
  • 7,701
  • 5
  • 29
  • 44
  • See as well: https://bugs.launchpad.net/ubuntu/+source/git/+bug/786942 – kenorb Jul 19 '12 at 11:03
  • Related: http://stackoverflow.com/questions/7584605/git-svn-dcommit-fails-because-the-repository-name-contains-a-space There is patch available there. – kenorb Oct 26 '12 at 08:25

5 Answers5

31

The tag on SVN has a space in it, but the tag in git had this space converted to %20 (URL encoded). To solve it just manually add a new tag with the verbatim name:

cd .git/refs/remotes/tags/
mv Sync%20Controllers Sync\ Controllers

Then run the git svn clone command again.

(Normally you'd do this with git tag OLDTAG NEWTAG but git was not allowing me to define a tag with a space in. The tag files are simply text files containing the hash of the relevant commit.)

Red XIII
  • 5,771
  • 4
  • 28
  • 29
Benjie
  • 7,701
  • 5
  • 29
  • 44
  • 4
    I tried that solution however, I get the following error: `fatal: Reference has invalid format: 'refs/remotes/tags/WITH SPACE'`. How to solve that? – D.R. Jun 25 '14 at 07:28
  • (I'm using git version 1.8.3.msysgit.0) – D.R. Jun 25 '14 at 07:30
  • This worked for me with a tag with a `~` character in the file name as well. Thanks. – Jonathan Hall Aug 18 '14 at 10:01
  • Hi, do you know how to workaround it in case of branches? http://stackoverflow.com/questions/33477630/migrating-svn-to-git-branches-with-white-space-in-the-names – Idemax Nov 02 '15 at 12:37
  • 2
    Probably the same but `cd .git/refs/heads/` or `cd .git/logs/refs/heads/` instead – Benjie Nov 19 '15 at 16:56
  • I also tried renaming but, like D.R. above, I obtain the error `fatal: Reference has invalid format`. I am using GIT 1.8.3.1 and SVN 1.8.11 – jplandrain Nov 26 '15 at 15:27
  • I ran in a simular problem, but when i tried to rename the conflicting file, it didn't exist in the path, in my case being refs/remotes/origin/CONFLICTING_FILE. My solution was to rename the entry corresponding to the CONFLICTING_FILE in the .git/packged-refs, removing the offending characters. – alcamla Mar 29 '17 at 13:32
  • 2
    upadating .git/packged-refs and replacing all the %20 with spaces fixed it for me... git 2.18.0 – MSillence Aug 13 '18 at 20:27
  • @MSillence Life saver. Ran into this today after a network timeout failure after running git svn clone for 24hrs. Modifying .git/packaged-refs and removing %20 allowed it all to continue where it left off. – James Manes Nov 17 '22 at 18:20
5

You may use git-svn server-side alternative, SubGit in order to avoid many of git-svn translation problems.

I'm a SubGit developer and could say that we worked a lot to resolve character translation issues like the one above; in this particular case tag would be translated to a refs/tags/Sync+Controllers tag.

Note also, that git-svn has translated Subversion tag as a branch instead of a tag.

  • Do I have to install SubGit on the server or it's not necessary? What if I don't have admin access to my svn repo? – kenorb Oct 26 '12 at 08:24
  • With SubGit 2.0 you do not have to have an admin access to your repository. You would need to enable pre-revprop-change hook to get a full featured authors mapping, but chances are that it is already enabled. Check http://subgit.com/eap/ for more details. – Alexander Kitaev Nov 16 '12 at 17:35
5

I ran into this issue today, and considered this branch which contains a pace in it is not important, i just run

git branch -r -d partialPayment%202.4

And re-run git svn fetch It skipped current branch and continue grabbing the next one.

i.n.n.m
  • 2,936
  • 7
  • 27
  • 51
Jason.chen
  • 61
  • 1
  • 3
1

I'm using git 1.29.2 and getting the issue too. Additionlly it is running into a Windows Server 2016 and git is under cygwin.

Was checking into /GitMigration/.git/svn/refs/remotes/origin, and the folder is there with blank spaces not %20 so nothing to change on it.

However into the packed-refs the tag that is producing the problem does not appears, no name and no hash.

The problem should has another related issue with something else that produce the error, not just this.

Looking into the ./.git/config found a series of repetitions of the following lines:

branches = server/branches/*:refs/remotes/origin/*
tags = server/tags/*:refs/remotes/origin/tags/*

That are producing each time i did run the git-svn clone sentence. So i did remove those from the config file, save it and run again, but this time using git svn fetch, to prevent get again the lines duplicated, and voala !! Problem solved.

JRod
  • 151
  • 1
  • 5
0

I believe the problem with spaces is fixed in Git >= 1.8.0 (See: #786942).

So you should upgrade it.

I've tested it and it seems to work in the recent version of git.

See GitHub Home page: https://github.com/git/git

kenorb
  • 155,785
  • 88
  • 678
  • 743