git svn clone 导致空目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11966525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:20:21  来源:igfitidea点击:

git svn clone results in empty directory

gitsvn

提问by tom eustace

I have an svn repository with project structure:

我有一个带有项目结构的 svn 存储库:

/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:

我想克隆projectA。当我运行时:

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?

我没有收到任何错误,并且在新的 projectA 目录下创建了一个 git 存储库。但是目录是空的。我错过了什么吗?

采纳答案by tom eustace

Below command did the job:

下面的命令完成了这项工作:

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

回答by wspeirs

My problem was using the -sor --stdlayoutbecause my svn repo did NOT have a standard layout (trunk, branches, tags).

我的问题是使用-sor--stdlayout因为我的 svn repo 没有标准布局(主干、分支、标签)。

回答by kfriend

For anyone including the authors-fileoption, git svn clonewill stop completelyif 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.

对于包含该authors-file选项的任何人,如果在提供的作者文件中遇到没有查找值的作者,git svn clone则将完全停止。如果您不注意,git 对此的“警报”可能看起来像是 repo 已完成克隆,并且不会说明该过程未完成。除了 .git 之外,repo 的目录将为空。

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

如果添加丢失的作者,然后重新运行确切的命令,git 将在它停止的地方继续。

回答by nelisa

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

我遇到了同样的问题,它通过使用 --no-metadata 参数解决了。在你的情况下,这相当于

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

回答by IRQ

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

如果您使用 HTTP 或 HTTPS 传输(即您的存储库 URL 以 HTTP[s] 开头),您需要提供有效的SVN用户名。

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

-s is an alias for --stdlayout

-s 是 --stdlayout 的别名

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

但是,我只需要指定 --username 选项一次,随后的调用无需它即可工作。我猜它缓存了用户名。

回答by morgue

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

有一个类似的问题,在目录中执行 'git reset --hard HEAD' 似乎创建了文件。

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

.git/objects 非常大,所以我猜这些文件是从 svn 导入到 git 中的,只是没有被检出,或者其他什么。

回答by U007D

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

就我而言,克隆操作没有正确完成。git svn clone会在结帐中途失败。一旦我解决了这个问题,它会在克隆操作后自动进行结账——不再是空文件夹。

[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:

git svn clone --preserve-empty-dirs <repo>对我来说尝试失败了。在网上搜索后,我找到了https://www.semitwist.com/articles/article/view/the-better-svn-git-guide,部分内容是:

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.

这部分有点烦人。从 v1.7.7 开始,Git 有一个 --preserve-empty-dirs。问题是,这该死的东西坏了。如果您尝试按原样使用它,则整个操作可能会在中途失败。它必须被修复。

首先,找到你的 git-svn 文件:

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

$ find 2>/dev/null / -type f | grep -l "无法剥离"

对我来说,它位于 /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.

注意:它不再在 git-svn 中(至少不在 git 2.7.0 中)。我在/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

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 dieto printand save. Your git-svn is now fixed.

现在,在这个 git-svn 文件中,搜索die "Failed to strip path. ([取决于您的 git 版本,] 它 [可能] 位于第 4583 行附近。更改dieprint并保存。您的 git-svn 现在已修复。

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

git svn clone --preserve-empty-dirs <repo>现在应该按预期运行。

回答by markus

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

我无法检查这是否有效,但请尝试:

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