为什么我会收到此错误消息?
11 回答
--no-metadata
我收到此消息是因为使用选项克隆了 svn 存储库。也许您的问题也是如此。
在没有该选项的情况下克隆它时一切都很好。
当新的克隆将来成为规范源时,该--no-metadata
选项旨在克隆 SVN 存储库。git
它缺乏向上游提交回 SVN 的能力,因为它无法跟踪 git clone 和上游 SVN 之间的差异。
(张贴乍得的“问题”作为答案,固定格式和错别字。)
此错误消息有几个原因。
第一个,是最常见的。您的 git 存储库中有两个不相交的历史记录:您在 git 中创建的历史记录,以及来自远程 svn 存储库的历史记录。
为了解决这个问题,你需要让你的 git 存储库和 svn 存储库共享一个共同的祖先,以便 git 可以确定哪些提交改变了什么。
以下文章讨论了如何解决该问题:
问题的第二个可能原因是如果您有早期版本的 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
无法从工作树中确定上游 svn 信息或
git svn rebase
无法确定上游 svn 信息工作树历史或
git svn dcommit
无法从 HEAD 历史记录中确定上游 SVN 信息
如果您收到上述错误消息,第一步是检查您的 git 版本。如果您运行的旧 git 版本 <= 1.6.3.3.*,在我的情况下是 (msysGit),那么解决问题的最简单方法是更新到最新版本的 git,例如 1.6.4.*。
下一篇文章更详细地讨论了这个问题。
就我而言,svn repo 中的 HEAD 应该与 git repo 中的 HEAD 匹配。这应该可以解决问题:
git update-ref refs/remotes/git-svn refs/remotes/origin/master
例如,如果您为 svn trunk 使用不同的 git 分支,svntrunk
则应该引用该分支,即:
git update-ref refs/remotes/git-svn refs/remotes/origin/svntrunk
在我错误地将-s
/--stdlayout
参数添加到没有“标准 Subversion 布局”的 Subversion 存储库的命令后git svn clone
,我收到了此消息,和相对路径。trunk
tags
branches
(我通常克隆的 Subversion 存储库确实有标准的相对路径,所以当我使用常用命令克隆一个没有它们的 Subversion 存储库时git svn clone
,我收到了这条神秘的消息。该消息 100% 正确,但几乎 100% 没用当试图找出问题所在时。)
遇到同样的问题,这里是基于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...
当您结帐新创建的 SVN 存储库时,您也可能会收到此错误。
我已经解决了这个问题
- 首先通过 svn 命令进行初始提交
- 然后使用 git svn 命令克隆 repo。
此问题的另一个原因是svn-remote.svn.rewriteRoot
选项错误(有关使用此问题的说明,请参阅此答案)。
如果设置git-svn-id
了 URL,则从 Subversion 导入的提交中的行必须与 URL 匹配。rewriteRoot
我收到这条消息是因为我对git 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 repo 与 svn 同步,然后其他人都git config --add remote.origin.fetch refs/remotes/*:refs/remotes/*
必须获取 svn 同步的分支。)
它也发生在我身上。而且我不记得做过什么不寻常的事情。SVN repo 存在,Git 版本是最新的。我想提交给 SVN 的本地 git repo 中有 2 个提交。但是当我跑的时候:
git svn dcommit
我得到了错误。
git svn fetch
和
git svn rebase
没有帮助。运行它们后我得到了同样的错误。
我认为问题可能是由于我之前做了 2 次本地 git 提交的压缩。如果这是我仍然不明白为什么在这种情况下壁球是一个问题的原因(如果您知道,请发表评论)。
无论如何,我通过将 svn repo 再次克隆到另一个工作目录来解决问题。
git svn clone .../trunk
将有问题的 git 存储库添加为远程存储库:
git remote add last /cygdrive/c/data/problem_repo
并对所有尚未移至 SVN 的提交进行了挑选。之后我可以成功运行:
git svn dcommit
另一个可能的原因:如果你有一个 svn-remote..rewriteUUID 配置集,git-svn 可能无法为存储库找到正确的元数据。例如,您可能有这样的事情(请参阅 git-svn 手册页,了解您为什么要这样做):
[svn-remote "svn"]
url = svn://read-write.test.org
fetch = trunk/project:refs/remotes/trunk
rewriteRoot = http://read-only.test.org/svn
rewriteUUID = 1234-abcd
... 其中 1234-abcd 是只读镜像的 UUID。当你 'git svn fetch' 时,你可能会得到这个文件:
.git/svn/refs/remotes/trunk/.rev_map.5678-dcba
... 其中 56780-dcba 是读写存储库的 UUID。解决方法是:
$ mv .git/svn/refs/remotes/trunk/.rev_map.5678-dcba \
.git/svn/refs/remotes/trunk/.rev_map.1234-abcd
不能确定这是否是一个持久的解决方案,即,下次你“git svn fetch”时可能会感到困惑。可能会尝试使用符号链接而不是“mv”,我还没有尝试过。
我在使用 BFG Repo-Cleaner https://rtyley.github.io/bfg-repo-cleaner/并重写了 git 历史记录(故意)之后看到了这一点,然后再次尝试 git svn fetch。该消息显示 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