Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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_Github_Pull Request_Git Subtree_Git Rewrite History - Fatal编程技术网

Git 如果我从主回购协议中拆分一个子树并创建一个新的回购协议,我的旧请求会发生什么?

Git 如果我从主回购协议中拆分一个子树并创建一个新的回购协议,我的旧请求会发生什么?,git,github,pull-request,git-subtree,git-rewrite-history,Git,Github,Pull Request,Git Subtree,Git Rewrite History,我有一个很大的代码库,我正在评估将某些部分拆分成较小存储库的策略。使用git子树分割,我能够分离出我想要的目录&提交历史似乎完好无损 这就是说,假设我继续使用这种方法,我的旧请求(包括Github中分离目录的代码)会发生什么情况 它们仍然会显示对旧代码的引用,还是更改只会引用仍在原始代码库中的代码 感谢您的帮助。从git子树拆分新创建的repo将只包含您在指定目录中所做更改的提交 假设原始git repo文件结构如下: Root |___ file1 |___ file2 |___

我有一个很大的代码库,我正在评估将某些部分拆分成较小存储库的策略。使用git子树分割,我能够分离出我想要的目录&提交历史似乎完好无损

这就是说,假设我继续使用这种方法,我的旧请求(包括Github中分离目录的代码)会发生什么情况

它们仍然会显示对旧代码的引用,还是更改只会引用仍在原始代码库中的代码

感谢您的帮助。

从git子树拆分新创建的repo将只包含您在指定目录中所做更改的提交

假设原始git repo文件结构如下:

Root
|___ file1      
|___ file2
|___ subfolder/
         |___ file3
         |___ file4
* 60a7f3e (master) change file3 for fourth time merge
*   954b730 Merge branch 'dev' into master
|\
| * b4b8d92 change file3 for second time merge
* |   35f7754 Merge branch 'dev' into matser
|\ \
| |/
| * fde1de3 change file3 and file4 on master branch
* | d4795a8 change file3 and file4 on master branch
|/
* cd367a2 add subfolder and it’s files
原始提交历史记录为:

*   8cb09fb (HEAD -> master) Merge branch 'dev' into matser
|\
| * e1e054c (dev) change file2 for fourth time merge
* | 6e8ee57 change file3 for fourth time merge
* |   ebdfb0b Merge branch 'dev' into master
|\ \
| |/
| * 5d93766 change file2 for thrid time merge
* | b95668a change file1 for thrid time merge
* |   09ca222 Merge branch 'dev' into matser
|\ \
| |/
| * d3dc890 change file3 for second time merge
* | 5818123 change file1 for second time merge
* |   cb39f04 Merge branch 'dev' into master
|\ \
| |/
| * 4dc4aaa change file3 and file4 on dev branch
* | fef775c change file3 and file4 on master branch
|/
* d8d81e6 add subfolder and it’s files
* 5446ea3  change file1
如果使用git子树拆分将子文件夹拆分为新的git repo,则只有更改子文件夹file3和file4的提交才会显示在新的repo提交历史记录中。新回购提交历史记录如下:

Root
|___ file1      
|___ file2
|___ subfolder/
         |___ file3
         |___ file4
* 60a7f3e (master) change file3 for fourth time merge
*   954b730 Merge branch 'dev' into master
|\
| * b4b8d92 change file3 for second time merge
* |   35f7754 Merge branch 'dev' into matser
|\ \
| |/
| * fde1de3 change file3 and file4 on master branch
* | d4795a8 change file3 and file4 on master branch
|/
* cd367a2 add subfolder and it’s files
正如您在原始回购协议中看到的:

对于第一次提交5446ea,它只更改了子文件夹目录中的file1,因此提交不会显示在新的repo中。 因为commit 5818123需要第二次合并,因为它也只更改了file1,所以commit不会显示在新的repo中。 对于提交第三次合并的b95668a、5d93766和ebdfb0b,它们都不会在子文件夹中更改,因此它们不会显示在新的repo中。 对于commit e1e054c,它只更改了dev分支上的file2,因此它不会显示在新的repo中。 对于第四个合并的commit 8cb09fb,它将子文件夹file3和file4保持为与主分支上的第一个父commit 6e8ee57未更改的子文件夹相同的版本,因此commit也不会显示在新的repo中。
拉取请求的本质是存储库中的哈希ID。您的哈希ID和现有存储库将发生什么变化?这会告诉你拉请求发生了什么,拉请求就是一个分支。您甚至可以添加一行,如:fetch=+refs/pull/*/head:refs/remotes/origin/pr/*。尝试合并拉请求就像合并分支一样,具有通常的冲突解决方法。