代码之家  ›  专栏  ›  技术社区  ›  PhilPursglove

无法从头历史确定上游SVN信息

  •  59
  • PhilPursglove  · 技术社区  · 7 年前

    为什么会收到此错误消息?

    10 回复  |  直到 7 年前
        1
  •  33
  •   Twan    8 年前

    (把查德的“问题”作为答案,固定格式和打字错误。)

    导致此错误消息的原因有两个。

    第一,是最常见的。您的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
    

    无法从工作树或

    git svn rebase
    

    无法确定上游SVN信息工作树历史或

      git svn dcommit
    

    无法从头历史确定上游SVN信息

    如果您收到上述错误消息,第一步是检查您的Git版本。如果您运行的是较旧的Git版本<=1.6.3.3.*,那么解决此问题的最简单方法是更新到最新版本的Git,如1.6.4.*。

    以下 Article 更详细地讨论这个问题。

        2
  •  28
  •   slafs    10 年前

    我收到这个消息是因为克隆了 --no-metadata 选择权。也许你的问题也是这样。

    如果不选择克隆,一切都会好起来的。

    这个 --没有元数据 选项用于在新的 git 克隆将成为未来的标准源。它缺乏向上游SVN提交的能力,因为它无法跟踪Git克隆和上游SVN之间的差异。

        3
  •  14
  •   axel22    14 年前

    在我的例子中,SVN回购的头应该与Git回购的头匹配。 This 应该解决问题:

    git update-ref refs/remotes/git-svn refs/remotes/origin/master
    
        4
  •  9
  •   G8RDA    14 年前

    我错误地添加了 -s / --stdlayout 参数 git svn clone 命令进行颠覆性回购 有“标准颠覆布局”的 trunk , tags branches 相对路径。

    (我通常克隆的SubversionRepo有标准的相对路径,所以当我克隆了一个SubversionRepo时,它没有使用我通常使用的路径 GIT-SVN克隆 命令,我收到了这个秘密消息。消息是100%正确的,但在试图找出问题所在时几乎100%无用。)

        5
  •  8
  •   Andrej    12 年前

    有同样的问题,这里是基于 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...
    
        6
  •  7
  •   mohammadthalif    13 年前

    当您签出新创建的SVN repo时,也可能会出现此错误。

    我已经解决了这个问题

    1. 首先通过svn命令执行初始提交
    2. 然后使用git svn命令克隆repo。
        7
  •  2
  •   Pirat    8 年前

    这个问题的另一个原因是错误的 svn-remote.svn.rewriteRoot 选项(见) this answer 有关使用说明)。

    这个 git-svn-id 从Subversion导入的提交中的行必须与 rewriteRoot 如果设置了URL。

        8
  •  2
  •   Nathan Kidd    13 年前

    我收到此消息是因为我使用了 git svn init 命令,但现有的git-svn集成只使用主机名。

    例如。 grep git-svn-id 显示:

    git-svn-id: svn://host/repo/...
    

    但我做到了:

    git svn init -Ttrunk svn://host.domain.com/repo
    

    (我们有一台机器,它定期将Git回购与SVN同步,其他人都有 git config --add remote.origin.fetch refs/remotes/*:refs/remotes/* 取下SVN同步的分支。)

        9
  •  0
  •   szager    12 年前

    另一个可能的原因是:如果设置了svn remote..rewriteuid config,则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”,我没有试验过。

        10
  •  0
  •   Mash    7 年前

    我用了bfg repo清洁剂后看到了这个 https://rtyley.github.io/bfg-repo-cleaner/ 重写了git历史(有意),然后再次尝试git svn fetch。 消息显示Git<->SVN匹配丢失。

    要解决这个问题,请阅读 https://git-scm.com/docs/git-svn
    最下面的节目是:

    $git_目录/svn/ */.RevIMAP。

    Subversion修订之间的映射 数字和Git提交名称。在一个存储库中, 未设置选项,可以从git svn id:行重新生成该选项。 在每次提交结束时(请参见上面的svn.nometadata部分 详情请参阅。

    要做到这一点,您需要在commit comments中包含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