【问题标题】:Errors Merging a Git Submodule into its Parent Repository in OS X在 OS X 中将 Git 子模块合并到其父存储库时出错
【发布时间】:2014-12-14 19:12:42
【问题描述】:

我已将父存储库“objc4”从 https://github.com/RandomDSdevel/objc4 克隆到本地路径“/Volumes/Development/Repositories/objc4”。此父存储库包含一个子模块“OBJC4-437.1-Runtime”,我已将其设置为在本地路径“/Volumes/Development/Repositories/objc4/runtime”上镜像https://github.com/macmade/OBJC4-437.1-Runtime 的内容。我想将此子模块合并到其父存储库中,并且已经尝试使用these instructions here 这样做。在第一次“警告!”之后,我参与了这个程序。文本中的部分,其作者指示将子模块指向的存储库的第二个副本克隆到与子模块的父存储库所在的目录相同的目录中,并运行他提供的脚本。根据我在博客文章的讨论部分中添加的一些 here 包含我一直提到的过程,即使在从 OS X 10.9.5 'Mavericks' 更新到 OS 之后,我仍然会收到来自该脚本的错误X 10.10.0 '优胜美地'。在我第一次尝试后,我再次尝试无济于事,显示在我对他的博客文章的第一条评论中,并且将包含我第二次尝试的足够输出,以便了解我在下面收到的错误消息。不过,我做错了什么?我是否从错误的目录运行 shell 脚本?我没有给它正确的文件路径吗?


第二次脚本运行尝试:

Bryces-HD-1-TB:runtime bryce$ /Users/bryce/Downloads/git-rewrite-to-subfolder
This script rewrites your entire history, moving the current repository root into a subdirectory.  This can be useful if you want to merge a submodule into its parent repository.

For example, your main repository might contain a submodule at the path src/lib/, containing a file called "test.c".  If you would merge the submodule into the parent repository without further modification, all the commits to "test.c" will have the path "/test.c", whereas the file now actually lives in "src/lib/test.c".

If you rewrite your history using this script, adding "src/lib/" to the path and the merging into the parent repository, all paths will be correct.

NOTE: This script might complete garble your repository, so PLEASE apply this only to a clone of the repository where it does not matter if the repo is destroyed.

Do you want to proceed? (y/n) y
Please provide the path which should be prepended to the current root. In the above example, that would be "src/lib". Please note that the path MUST NOT contain a trailing slash.

Please provide the desired path (e.g. 'src/lib'): /Volumes/Development/Repositories/objc4/runtime 
100644 f14f44cb3b69631fac2463fad25cd3b40b4dbc5b 0   /Volumes/Development/Repositories/objc4/runtime/.gitignore
100644 5342bd2b09a64ea93e3587d5d3e9d97966871555 0   /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.h
100644 d1e5617d8b3ed55f1d32e65f8af75c3ab914dc26 0   /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.m
100644 4b4584b9e7bd196fb0c1906b3ebcb37af52eac31 0   /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-i386.s
100644 c3f7332252a2b17f5d6a7e06bbd370f68909ce9f 0   /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-ppc.s
⋮
100644 b48f5e3581a430edc7984d7a72f6044d2618746c 0   /Volumes/Development/Repositories/objc4/runtime/objc.h
100644 af2830174561fa3a8d4a19996190992a8fa0f850 0   /Volumes/Development/Repositories/objc4/runtime/objcrt.c
100644 b3995456f9ee5860970abf496f2a2de591bfb4d9 0   /Volumes/Development/Repositories/objc4/runtime/objcrt.h
100644 c6047bbdb38ed2cd9d2bb7fee2d653d063874070 0   /Volumes/Development/Repositories/objc4/runtime/runtime.h
Please take a look at the printed file list. Does it look correct? (y/n) y
Rewrite 50d5519c12723f5d9ec2170bc45c144b25a8107e (1/5)Ignoring path /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.m
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-i386.s
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-ppc.s
⋮
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objc.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objcrt.c
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objcrt.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/runtime.h
mv: /Volumes/Development/Repositories/objc4/runtime/.git-rewrite/t/../index.new: No such file or directory
index filter failed: git ls-files -s | sed "s/  /   \/Volumes\/Development\/Repositories\/objc4\/runtime\//" | GIT_INDEX_FILE=${GIT_INDEX_FILE}.new git update-index --index-info && mv ${GIT_INDEX_FILE}.new ${GIT_INDEX_FILE}

第三次脚本运行尝试:

Bryces-HD-1-TB:runtime bryce$ /Users/bryce/Downloads/git-rewrite-to-subfolder
This script rewrites your entire history, moving the current repository root into a subdirectory.  This can be useful if you want to merge a submodule into its parent repository.

For example, your main repository might contain a submodule at the path src/lib/, containing a file called "test.c".  If you would merge the submodule into the parent repository without further modification, all the commits to "test.c" will have the path "/test.c", whereas the file now actually lives in "src/lib/test.c".

If you rewrite your history using this script, adding "src/lib/" to the path and the merging into the parent repository, all paths will be correct.

NOTE:  This script might complete garble your repository, so PLEASE apply this only to a clone of the repository where it does not matter if the repo is destroyed.

Do you want to proceed? (y/n) y
Please provide the path which should be prepended to the current root. In the above example, that would be "src/lib". Please note that the path MUST NOT contain a trailing slash.

Please provide the desired path (e.g. 'src/lib'): /Volumes/Development/Repositories/objc4/runtime
100644 f14f44cb3b69631fac2463fad25cd3b40b4dbc5b 0   /Volumes/Development/Repositories/objc4/runtime/.gitignore
100644 5342bd2b09a64ea93e3587d5d3e9d97966871555 0   /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.h
100644 d1e5617d8b3ed55f1d32e65f8af75c3ab914dc26 0   /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.m
100644 4b4584b9e7bd196fb0c1906b3ebcb37af52eac31 0   /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-i386.s
100644 c3f7332252a2b17f5d6a7e06bbd370f68909ce9f 0   /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-ppc.s
⋮
100644 b48f5e3581a430edc7984d7a72f6044d2618746c 0   /Volumes/Development/Repositories/objc4/runtime/objc.h
100644 af2830174561fa3a8d4a19996190992a8fa0f850 0   /Volumes/Development/Repositories/objc4/runtime/objcrt.c
100644 b3995456f9ee5860970abf496f2a2de591bfb4d9 0   /Volumes/Development/Repositories/objc4/runtime/objcrt.h
100644 c6047bbdb38ed2cd9d2bb7fee2d653d063874070 0   /Volumes/Development/Repositories/objc4/runtime/runtime.h
Please take a look at the printed file list. Does it look correct? (y/n) y
Rewrite 50d5519c12723f5d9ec2170bc45c144b25a8107e (1/5)Ignoring path /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Accessors.subproj:/objc-accessors.m
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-i386.s
Ignoring path /Volumes/Development/Repositories/objc4/runtime/Auto.subproj/objc-auto-ppc.s
⋮
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objc.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objcrt.c
Ignoring path /Volumes/Development/Repositories/objc4/runtime/objcrt.h
Ignoring path /Volumes/Development/Repositories/objc4/runtime/runtime.h
mv: /Volumes/Development/Repositories/objc4/runtime/.git-rewrite/t/../index.new: No such file or directory
index filter failed: git ls-files -s | sed "s/  /   \/Volumes\/Development\/Repositories\/objc4\/runtime\//" | GIT_INDEX_FILE=${GIT_INDEX_FILE}.new git update-index --index-info && mv ${GIT_INDEX_FILE}.new ${GIT_INDEX_FILE}


P。 S.:

即使我按照您在回答中给我的说明进行操作,我又遇到了麻烦。在这里,连同我的输入,是您的脚本在提示和错误消息方面向我吐出的内容:

Bryces-HD-1-TB:objc4 bryce$ /Users/bryce/Downloads/git-rewrite-to-subfolder
This script rewrites your entire history, moving the current repository root into a subdirectory. This can be useful if you want to merge a submodule into its parent repository.

For example, your main repository might contain a submodule at the path src/lib/, containing a file called "test.c".
If you would merge the submodule into the parent repository without further modification, all the commits to "test.c" will have the path "/test.c", whereas the file now actually lives in "src/lib/test.c".

If you rewrite your history using this script, adding "src/lib/" to the path and the merging into the parent repository, all paths will be correct.

NOTE: This script might complete garble your repository, so PLEASE apply this only to a clone of the repository where it does not matter if the repo is destroyed.

Do you want to proceed? (y/n) y
Please provide the path which should be prepended to the current root. In the above example, that would be "src/lib". Please note that the path MUST NOT contain a trailing slash.

Please provide the desired path (e.g. 'src/lib'): runtime
100644 7fe9c0cee579b7b5ccce3f903486557c01f58255 0   runtime/.gitmodules
160000 9569632f173948b503fa3e23187fbd3dbe124eb0 0   runtime/runtime
Please take a look at the printed file list. Does it look correct? (y/n) y
Rewrite 5119d79f8b4714e17fb23ea84fa7801ca71b896c (2/5)mv: /Volumes/Development/Repositories/objc4/.git-rewrite/t/../index.new: No such file or directory
index filter failed: git ls-files -s | sed "s/  /   runtime\//" | GIT_INDEX_FILE=${GIT_INDEX_FILE}.new git update-index --index-info && mv ${GIT_INDEX_FILE}.new ${GIT_INDEX_FILE}

【问题讨论】:

    标签: git terminal git-submodules osx-yosemite darwin


    【解决方案1】:

    看来您的问题是使用了绝对路径。

    Please provide the desired path (e.g. 'src/lib'): /Volumes/Development/Repositories/objc4/runtime
    

    此提示要求您为其提供父存储库中子模块的路径,而不是计算机上的绝对路径。这意味着,在您的情况下,路径将只是 runtime。我刚刚使用该路径选项运行脚本并成功地将子模块合并到父存储库中。

    【讨论】:

    • @x3r0:哦,等等;那没有用,所以我会将错误消息的详细信息添加到我原来的问题中(不过,我的空间不足了!)也许我需要从'runtime'中运行你的脚本并喂它'..?或者可能是因为您创建了这个脚本来使用比我旧的 OS X 和 Git 版本?以防万一,我已经安装了 OS X 10.10.0 'Yosemite' 和 Git 1.8.4。
    • 好像您在父存储库中运行它?您应该在子模块存储库中运行该命令。
    • 我将更新博文并尝试更清楚地了解需要在哪里运行:)
    • 还没有,它在我的待办事项列表上,但正如我提到的,我很忙。
    • 我知道这可能有点晚了,但我终于有时间更新帖子了:D 抱歉耽搁了。
    猜你喜欢
    • 2011-12-09
    • 2013-04-30
    • 2017-06-29
    • 1970-01-01
    • 2012-09-20
    • 1970-01-01
    • 2016-03-10
    • 2014-05-30
    • 2015-04-03
    相关资源
    最近更新 更多