问题描述
我正在尝试使用@VonC在此答案中的步骤将repository2
的master
分支的子文件夹合并到repository1
的master
分支中-
I'm trying to merge a subfolder of master
branch of repository2
into master
branch of repository1
, using the steps in this answer by @VonC - How do I merge a sub directory in git?
我成功地执行了前两个步骤(在repository1
的master
分支内添加repository2
远程,然后执行从repository2
到repository1
的空"合并).我的存储库的结构是这样的:
I perform the first two steps with success (adding the repository2
remote, within the master
branch of repository1
, then performing an 'empty' merge from repository2
to repository1
). The structure of my repositories is like this:
repository2/master
DataLib
MessagingLib.V2
.... files I want to merge into my repository1 branch
repository1/master
MessagingLib
.... files I want to merge the repository2 changes into
我已签出repository1
master
分支.因此对于git read-tree
,我使用以下命令:
I have repository1
master
branch checked out. So for the git read-tree
, I use this command:
git read-tree --prefix=MessagingLib.V2/ -u repository2/master:repository1/MessagingLib
但是我得到了错误
fatal: Not a valid object name repository2/master:repository1/MessagingLib
我需要什么read-tree
命令?
更新
这些也不起作用:
git read-tree --prefix=DataLib/MessagingLib.V2/ -u repository2/master:repository1/MessagingLib
git read-tree --prefix=DataLib/MessagingLib.V2/ -u repository2/master:repository1/master
推荐答案
由于我试图将repository2
中的子文件夹合并到repository1
中具有不同名称的子文件夹中,这一点使情况变得复杂.我将repository1
中的子文件夹重命名为MessagingLib.V2(以匹配repository2
上的名称),然后可以使用:
This was complicated by the fact that I was attempting to merge the subfolder from repository2
into a subfolder of a different name in repository1
. I renamed my subfolder in repository1
to MessagingLib.V2 (to match the name on repository2
), then I could use:
git read-tree --prefix=MessagingLib.V2/ -u repository2/master:DataLib/MessagingLib.V2
这篇关于Git错误,将存储库的子文件夹合并到其他存储库的子文件夹时,不是有效的对象名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!