为什么会出现这个错误信息?
我因为使用 --no-metadata
选项克隆 SVN 仓库而收到这条消息。也许你的问题也是这种情况。
如果不使用该选项,一切都正常。
--no-metadata
选项旨在克隆 SVN 仓库,使新的 git
克隆在未来成为规范来源。它缺少将更改提交回 SVN 上游的能力,因为它无法跟踪 git 克隆和 SVN 上游之间的差异。
(发布了Chad的“问题”作为答案,修复了格式和拼写错误。)
这个错误消息有几个原因。
第一个是最常见的。 在您的git存储库中有两个不相关的历史记录:您在git中创建的历史记录和来自远程svn存储库的历史记录。
要解决此问题,您需要使您的git存储库和svn存储库共享一个公共祖先,以便git可以找出哪些提交更改了什么。
下面的Article讨论了如何解决该问题:
问题的第二个可能原因是您使用早期版本的git(可能是Windows msysGit包),并且刚刚创建了一个与远程svn存储库通信的新git存储库。
例如:
git svn init svn://svn.xxx.xxx/xxx/trunk
git svn fetch -r BASE:10
或者
git clone svn://svn.xxx.xxx/xxx/trunk // Adds all the files in the revision...
当使用以下命令时,您将收到以下错误消息。
$ git svn info
Unable to determine upstream SVN information from working tree
$ git svn rebase
Unable determine upstream SVN information working tree history
$ git svn dcommit
Unable to determine upstream SVN information from HEAD history
以下文章将更详细地讨论这个问题。
在我的情况下,来自svn仓库的HEAD应该与来自git仓库的HEAD匹配。 这个 应该解决问题:
git update-ref refs/remotes/git-svn refs/remotes/origin/master
如果你在svn主干上使用不同的git分支,比如svntrunk
,应该引用那个分支,如下所示:git update-ref refs/remotes/git-svn refs/remotes/origin/svntrunk
refs/remotes/origin/master
实际上是refs/remotes/origin/svntrunk
,因为我将svn主干保留在另一个分支中。我在这里添加了这个问题的解决方法,以便与社区共享。 - ceztkogit clone
但之后**忘记了 git svn init
**!这个顺序是有效的:git clone
→ git svn init
→ git update-ref
。 - ulidtko我遇到了同样的问题,这里有一个基于http://eikke.com/importing-a-git-tree-into-a-subversion-repository/文章的解决方案:
$ git svn init http://server.com/svn/project/trunk/prototypes/proto1/
$ git svn fetch
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '/svn/!svn/bc/100/dcom/trunk/prototypes/ws' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
r147367 = 37c9910f794cb9cff7ca0d5d2eb26e1f0dabbc4d (refs/remotes/git-svn)
$ svn log http://server.com/svn/project/trunk/prototypes/proto1/
------------------------------------------------------------------------
r147367 | user | 2014-01-16 18:02:43 +0100 (Thu, 16 Jan 2014) | 1 line
proto1 home
------------------------------------------------------------------------
$ git log --pretty=oneline master | tail -n1
71ceab2f4776089ddbc882b8636aacec1ba5e832 Creating template
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #1
$ git show-ref git-svn
37c9910f794cb9cff7ca0d5d2eb26e1f0dabbc4d refs/remotes/git-svn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #2
$ echo "71ceab2f4776089ddbc882b8636aacec1ba5e832 37c9910f794cb9cff7ca0d5d2eb26e1f0dabbc4d" >> .git/info/grafts
$ git svn dcommit
Committing to http://server.com/svn/project/trunk/prototypes/proto1 ...
A README.md
A pom.xml
A src/main/java/.gitkeep
A src/main/resources/.gitkeep
A src/main/webapp/WEB-INF/web.xml
A src/main/webapp/index.html
A webapps/.gitkeep
Committed r147419
A README.md
A pom.xml
A src/main/java/.gitkeep
A src/main/resources/.gitkeep
A src/main/webapp/WEB-INF/web.xml
A src/main/webapp/index.html
A webapps/.gitkeep
r147419 = 6a8bda7262739306d0a6e17eaad2802737dedc35 (refs/remotes/git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
Unstaged changes after reset:
M pom.xml
M src/main/webapp/index.html
A .gitignore
Committed r147420
M pom.xml
M src/main/webapp/index.html
A .gitignore
r147420 = 749b5acec55c341672bca08d07de8c336b5a4701 (refs/remotes/git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
...etc...
-s
/--stdlayout
参数到git svn clone
命令后,得到了这个消息。git svn clone
命令克隆没有这些路径的Subversion仓库时,我收到了这个晦涩的消息。该消息是100%正确的,但在试图找出问题所在时几乎100%无用。)git svn clone
命令时,在svn url中添加了/trunk
选项,同时又加上了-s
选项。虽然和你的情况不完全相同,但是你的评论帮助我发现了我的错误。谢谢! - jeroengit svn init
命令中使用了FQDN,而现有的git-svn集成只使用主机名。grep git-svn-id
显示:git-svn-id: svn://host/repo/...
git svn init -Ttrunk svn://host.domain.com/repo
git svn init -Ttrunk svn://host.domain.com/repo
时,我遇到了这个错误。因此,我改为执行 git svn init -Ttrunk svn://host/repo
,然后一切正常。 - Nathan Kidd导致这个问题的另一个原因是错误的svn-remote.svn.rewriteRoot
选项(请参见此答案以获取有关使用它的说明)。
您从Subversion导入的提交中的git-svn-id
行必须与设置的rewriteRoot
URL匹配。
我在使用BFG Repo-Cleaner https://rtyley.github.io/bfg-repo-cleaner/并重写git历史(有意),然后尝试再次进行git svn获取后看到了这个消息。
消息显示git <-> svn匹配已丢失。
要解决此问题,请阅读https://git-scm.com/docs/git-svn
底部显示:
$GIT_DIR/svn/*/.rev_map.
Subversion修订号和Git提交名称之间的映射。在未设置noMetadata选项的存储库中,可以从每个提交结尾处的git-svn-id:行中重新构建它(有关详细信息,请参见上面的svn.noMetadata部分)。
您需要在提交注释中添加git-svn-id注释才能执行此操作。如果是这样,您可以删除.rev_map.*文件并重新构建它。
rm .git/svn/refs/remotes/git-svn/.rev_map.*
git svn info
Rebuilding .git/svn/refs/remotes/git-svn/.rev_map.{snip} ...
...
Done rebuilding .git/svn/refs/remotes/git-svn/.rev_map.{snip}
Path: .
...and then regular git svn info output
git svn dcommit
我遇到了错误。
git svn fetch
并且
git svn rebase
没有帮助。 运行它们后,我收到了相同的错误。
我认为问题可能是由于之前对2个本地git提交进行了压缩所致。 如果这是原因,我仍然不明白为什么在这种情况下压缩会成为问题(如果您知道,请评论)。
无论如何,我通过将svn repo克隆到另一个工作目录中来解决了问题。
git svn clone .../trunk
git remote add last /cygdrive/c/data/problem_repo
我对所有还没有移动到SVN的提交进行了挑选。之后,我成功地运行了以下命令:
git svn dcommit