Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git子树合并忽略--前缀_Git_Git Subtree - Fatal编程技术网

git子树合并忽略--前缀

git子树合并忽略--前缀,git,git-subtree,Git,Git Subtree,我在Windows上的git 1.8.3出现了一个奇怪的错误。使用git子树,我获取了一个要在两个项目之间共享的文件,并将其推送到另一个存储库 因此,在repo1中,我做了以下工作: # push script git subtree split --prefix=shared-dir --rejoin --branch split git push shared-repo split:master git branch -D split # pull script git fetch sha

我在Windows上的git 1.8.3出现了一个奇怪的错误。使用
git子树
,我获取了一个要在两个项目之间共享的文件,并将其推送到另一个存储库

因此,在repo1中,我做了以下工作:

# push script
git subtree split --prefix=shared-dir --rejoin --branch split
git push shared-repo split:master
git branch -D split
# pull script
git fetch shared-repo
git subtree merge --prefix=shared-dir shared-repo/master
在这两种回购中,
共享回购
指的是包含共享代码的远程回购。共享代码将驻留在具有相同名称的目录中

在报告2中,我这样做了:

# push script
git subtree split --prefix=shared-dir --rejoin --branch split
git push shared-repo split:master
git branch -D split
# pull script
git fetch shared-repo
git subtree merge --prefix=shared-dir shared-repo/master
我希望它做的是获取共享文件并将其放入repo2目录下的
/shared dir/
。发生的情况是,文件被放在存储库的根目录中

将文件移动到正确的文件夹,提交并执行与repo1的push脚本类似的操作,会导致push被拒绝,因为它表明push不是快进的。再次运行pull脚本表示所有内容都是最新的

我被踩死了,在互联网上搜索没有发现其他人有类似的问题。怎么了?我能怎么办


更新:Ubuntu12.04上的git 1.7.9.5也发生了同样的情况,它的
git子树
脚本是大约两周前从git存储库中获取的。我还将命令改为
--prefix=./shareddir/
,但没有效果


有趣的是,
git子树
创建了
shared dir
目录,但将共享文件放在根目录中,而不是该目录中。

问题是,第一次将共享目录添加到存储库时,应使用以下方法:

git subtree add --prefix=... .../...

我在从Github拉取的git回购上遇到了类似的问题:
git子树拉取
正在删除回购的内容。使用
git子树add--prefix
添加前缀无效,因为已添加前缀

唯一对我有效的解决方案是删除目录,然后再次添加前缀。例如:

rm -rf JSQMessagesViewController
# now commit all, then add
git subtree add --prefix JSQMessagesViewController https://github.com/jessesquires/JSQMessagesViewController master --squash
# Now the pull will work!
git subtree pull --prefix JSQMessagesViewController https://github.com/jessesquires/JSQMessagesViewController master --squash

当然,我们欢迎更好的解决方案。

知道为什么会发生这种情况吗?