git svn importing a branch with a trailing space

I’m importing a svn repository into git using git svn. I’m using Git-1.8.0-preview20121022 on Windows Server 2008 R2.

The import’s been running for a while and has fetched the first 4000 revisions without incident. However, it now seems to have come across a branch name with a trailing space and it has fallen over.

  • how do i identify files/directories that were added or removed in a git commit?
  • MATLAB git by command window
  • eclipse / egit to see previous version of a file (git)
  • Homebrew: how to use the formula from the pull request
  • extra branches created by git svn clone
  • How to remove GitHub commit along with it's history?
  • $ git svn fetch
    Found possible branch point: =>, 3976
    Found branch parent: (refs/remotes/Release 20110929 ) 691fb7f7d11cbb1afe35106f60a1d117ba415f4c
    fatal: Unable to create 'd:/GitMigration/project/.git/svn/refs/remotes/Release 20110929 /index.lock': No such file or directory
    read-tree 691fb7f7d11cbb1afe35106f60a1d117ba415f4c: command returned error: 128

    This branch doesn’t exist any more so I can’t change the name in the normal way. The directory exists without the trailing space in the name but I can’t find a way to rename it that preserves the space.

    Is there anything I can do about this?

  • Git server configuration
  • How can I check in a bash script if my local git repo has changes
  • Is there any reason NOT to use git-masquerading-as-cvs as an upgrade to cvs?
  • Changing “git status” output colors in Posh-Git
  • Any way to get around cloning a git submodule?
  • Is there a way to mount a git branch (read only) on linux?
  • 3 Solutions collect form web for “git svn importing a branch with a trailing space”

    The root cause of the issue – GIT creates a directory with a trailing space but in fact its name is truncated. For example Windows mkdir likes to do that. GIT doesn’t expect that and continues to use name with a space and fails to find a dir.

    It can be fixed manually. Use FAR, GnuWin or any other tool which can make a directory with a trailing space. Then rename “d:/GitMigration/project/.git/svn/refs/remotes/Release 20110929” to “d:/GitMigration/project/.git/svn/refs/remotes/Release 20110929”. As you can see that’s the directory GIT was expecting to find.

    Then run git svn fetch again.

    In the end I gave up on importing this in Windows. There are hacky solutions out there I’m sure, but it’s much easier just to do this in Linux then pull it from there to Windows. This should work fine as long as the branch isn’t current.

    There is a manual workaround this issue. Try creating the the DIR manually.
    To avoid trimming of white trailing white space you can add “\?\ at the beginning of the path” in cmd command. e.g.

    mkdir "\\?\d:\GitMigration\project\.git\svn\refs\remotes\Release 20110929 "
    Git Baby is a git and github fan, let's start git clone.