Git error Not a valid object name, when merging subfolder of repository into subfolder of different repository

邮差的信 提交于 2020-07-19 18:08:39

问题


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?

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

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

But I get the error

fatal: Not a valid object name repository2/master:repository1/MessagingLib

What's the read-tree command I need?

Update

These don't work either:

git read-tree --prefix=DataLib/MessagingLib.V2/ -u repository2/master:repository1/MessagingLib

git read-tree --prefix=DataLib/MessagingLib.V2/ -u repository2/master:repository1/master


回答1:


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



来源:https://stackoverflow.com/questions/62927619/git-error-not-a-valid-object-name-when-merging-subfolder-of-repository-into-sub

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!