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 Cherry Pick - Fatal编程技术网

强制git从嵌套存储库更新未跟踪的文件

强制git从嵌套存储库更新未跟踪的文件,git,git-cherry-pick,Git,Git Cherry Pick,我目前正在使用一个最近为了近距离采购而被拆分的存储库——模块已经从“主”存储库转移到自己的存储库中 panel/ file.a file.b module1/ [untracked by panel repository, instead tracked in own repository now] templates/ base.html ... views.py 然而,当模块1存储库仍然

我目前正在使用一个最近为了近距离采购而被拆分的存储库——模块已经从“主”存储库转移到自己的存储库中

panel/
    file.a
    file.b
    module1/ [untracked by panel repository, instead tracked in own repository now]
        templates/
            base.html
            ...
        views.py
然而,当
模块1
存储库仍然是
面板
的一部分时,在这次拆分之前仍有工作要完成。我的问题是如何处理这次拆分前后的提交—我目前正在尝试
挑选
提交,同时更改
面板
模块1
中的文件,该提交是在两个存储库都是
面板
的一部分时创建的。(没有更改目录结构,只有git的存储库视图)

当我在主存储库的目录中选择时:

nasonfish@nasonfish ~/P/P/p/panel2> git cherry-pick 8b7316d1ebff49e95a7971f88e669f50d9cbbf86
error: refusing to lose untracked file at 'panel/module1/views.py'
error: refusing to lose untracked file at 'panel/module1/templates/module1/view-hdr.html'
error: refusing to lose untracked file at 'panel/module1/templates/module1/view-base.html'
error: refusing to lose untracked file at 'panel/module1/templates/module1/base.html'
error: could not apply 8b7316d... mybranch: This is my commit
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
nasonfish@nasonfish~/P/P/P/panel2>git cherry pick 8b7316d1ebff49e95a7971f88e669f50d9cbbf86
错误:拒绝在“panel/module1/views.py”处丢失未跟踪的文件
错误:拒绝丢失位于“panel/module1/templates/module1/view hdr.html”的未跟踪文件
错误:拒绝丢失位于“panel/module1/templates/module1/view base.html”的未跟踪文件
错误:拒绝丢失位于“panel/module1/templates/module1/base.html”的未跟踪文件
错误:无法应用8b7316d。。。mybranch:这是我的承诺
提示:解决冲突后,标记更正的路径
提示:使用“git add”或“git rm”
提示:并使用“git commit”提交结果

我可以看出,我并不希望删除存储库中的文件或将其添加到主存储库中,因为这只是撤消了分离并合并了存储库-但我正在尝试应用
cherry pick
来提交基本存储库和子存储库中的文件,而不合并两者。那么,有没有一种方法可以强制git将独立嵌套存储库中的文件视为主存储库的一部分,以某种方式允许在存储库分离之前进行提交?

在考虑如何在不考虑其存储库的情况下对文件应用某种提交之后,我的眼睛转向生成要应用的补丁

我首先发现:

然后我使用
git apply
应用了我的补丁程序(因为我不能肯定补丁程序会与我拥有的完美合并,所以我应用了开关,以便合并我可以合并的内容,并转储手动合并不起作用的内容):

然后,我在我的存储库中搜索了
.rej
文件,这些文件包含我必须手动合并的修补程序,并使用这些文件将更改应用于它们要合并到的文件

在那之后,我知道我已经在我的存储库中应用了更改,我可以简单地将目录更改到每个存储库中,并使用
git commit
指示我已经合并了什么

git format-patch -1 8b7316d1ebff49e95a7971f88e669f50d9cbbf86
git apply 0001-permissions-Add-a-new-user-permissions-system-that-c.patch --reject