问题
I have cloned a parent repository 'objc4
' from https://github.com/RandomDSdevel/objc4 to the local path '/Volumes/Development/Repositories/objc4
.' This parent repository contains a submodule 'OBJC4-437.1-Runtime
' which I have set up to mirror the contents of https://github.com/macmade/OBJC4-437.1-Runtime at the local path '/Volumes/Development/Repositories/objc4/runtime
.' I would like to merge this submodule into its parent repository and have already attempted to do so using these instructions here. I am at the part of this procedure after the first 'Warning!' section in the text where its author directs one to clone a second copy of the repository to which your submodule points into the same directory as the one in which your submodule's parent repository resides and to run a script that he provides. Per some additions that I have made here to the discussion section of the blog post containing the procedure to which I have been referring, I continue to receive errors from this script even after updating from OS X 10.9.5 'Mavericks' to OS X 10.10.0 'Yosemite.' I've tried again to no avail after my first attempt, displayed in my first comment on his blog post, and will include enough of the output of my second two attempts to give an idea of what error messages I am receiving below. What am I doing wrong, though? Am I running the shell script from the wrong directory? Am I not giving it the right file paths?
Second Script Run Attempt:
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}
Third Script Run Attempt:
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.:
I've run into trouble again even though I followed the instructions you gave me in your answer. Here, along with my input, is what your script spewed out at me in terms of prompts and error messages:
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}
回答1:
It seems that your problem is the usage of an absolute path.
Please provide the desired path (e.g. 'src/lib'): /Volumes/Development/Repositories/objc4/runtime
This prompt expects you to provide it with the path to the submodule inside your parent repository, not an absolute path on your computer. That means that, in your case, the path would simply be runtime
. I just ran the script with that path option and successfully merged the submodule into the parent repository.
来源:https://stackoverflow.com/questions/26454893/errors-merging-a-git-submodule-into-its-parent-repository-in-os-x