47

I have an svn repository with project structure:

/root/projectA/trunk
/root/projectA/branches
/root/projectA/tags

/root/projectB/trunk
/root/projectB/branches
/root/projectB/tags 

I want to clone projectA. When I run:

git svn clone -r <revision number>:HEAD <url>/root/projectA

I get no errors and a git repository is created under the new projectA directory. However the directory is empty. Am I missing soemthing?

1

8 Answers 8

69

My problem was using the -s or --stdlayout because my svn repo did NOT have a standard layout (trunk, branches, tags).

Sign up to request clarification or add additional context in comments.

1 Comment

Same here. I had a single repo with a bunch of projects, each with trunk, tags, and branches -- but that is NOT standard layout.
30

Below command did the job:

  git svn clone -r HEAD <url>/root/projectA 

Comments

17

For anyone including the authors-file option, git svn clone will stop completely if it encounters an author without a lookup value in the supplied authors file. If you're not paying attention, git's "alert" for this may look like the repo has finished cloning, and doesn't state that the process is not complete. The repo's directory will be empty, besides .git.

If you add the missing author, then rerun the exact command, git will continue where it halted.

3 Comments

How can you find out which author is missing?
@LovesTha, the missing author will be output on the screen.
This was exactly my problem, and it was very confusing. I had a "mostly" standard layout, but some random dirs in root as well - I assumed this, or perhaps the old version of subversion was the problem when in fact it was the problem with missing authors. I had intentionally deleted some authors that I didn't want to rewrite, assuming it was optional and not realizing the last warning on the screen was really a fatal error. Thanks!
2

I've had the same problem and it was solved by using the --no-metadata argument. In your case, this would amount to

git svn clone -r <revision number>:HEAD <url>/root/projectA --no-metadata

1 Comment

Please see the pros and cons of using no-metadata from the link - git-scm.com/docs/git-svn before using this option.
1

If you use the HTTP or HTTPS transports (i.e. your repository URLs start with HTTP[s]), you need to provide a valid SVN username.

git svn clone -s https://svn.example.com/root/projectA --username <SVN username>

-s is an alias for --stdlayout

However, I only had to specify the --username option once and subsequent calls worked without it. I guess it caches the username.

Comments

1

Had a similar issue, executing 'git reset --hard HEAD' in the directory seemed to create the files.

.git/objects was quite large, so I guess the files were imported from svn into git, they just weren't checked out, or something.

Comments

1

In my case, the clone operation wasn't completing properly. git svn clone would fail partway through the checkout. Once I fixed the issue, it automatically did the checkout after the clone operation--no more empty folder.

[Update] Here's what worked in my case:

Attempting git svn clone --preserve-empty-dirs <repo> failed for me. After scouring the net, I found https://www.semitwist.com/articles/article/view/the-better-svn-git-guide, which says, in part:

This part is a bit of an annoyance. From v1.7.7 onward, Git has a --preserve-empty-dirs. Problem is, the damn thing's broken. If you try to use it as-is, the whole operation will likely just fail partway through. It has to be fixed.

First, find your git-svn file:

$ find / 2> /dev/null | grep git-svn

$ find 2>/dev/null / -type f | grep -l "Failed to strip"

For me, it was at /usr/libexec/git-core/git-svn.

Note: It’s not in git-svn any more (at least not in git 2.7.0). I found it in /usr/lib/perl5/vendor_perl/5.22/Git/SVN/Fetcher.pm.

Open the target file in your favorite editor:

sudo <your-favorite-editor> path/to/file

Now, in this git-svn file, search for die "Failed to strip path. ([Depending on your version of git,] it [may] be somewhere near line 4583. Change the die to print and save. Your git-svn is now fixed.

git svn clone --preserve-empty-dirs <repo> should now behave as expected.

3 Comments

What was the issue?
Sorry, @DDivita. I'm not sure why I didn't put the solution I found in my reply. Updated.
Still an issue for git 2.34, file was located at /usr/share/perl5/Git/SVN/Fetcher.pm (WSL Ubuntu 22.04)
0

I could not chech whether this is working, but try:

git svn clone --stdlayout <url>/root/projectA/

1 Comment

No difference. still end up with an empty directory!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.