git子树,查看提交

时间:2017-09-04 04:44:12

标签: git merge branch git-subtree

当我使用git subtree add add命令将项目合并到另一个项目时,历史记录与目标分支合并,与正常的三向合并类似。

*   375c6d0 Add 'somestuff/' from commit '428761aea39560d87f4dd096366f7324bde728f5'
|\
| * 428761a Add new line to Readme
| * 15b1175 Edit Readme
| * c418c7d Initial commit
* 3782cdd fixes
* bed10f8 parent
* c3dd312 resources filtering
* db3cbd2 property
* 7cc3bc3 submodules
* 3bb1296 Initial commit

在此示例中,分支是历史记录来自与git sutbree add合并的另一个项目。该命令的作用是将项目放在主项目下的新子文件夹中。但是,当我查看提交时,文件路径相对于合并项目显示,而不是相对于主项目(合并项目现在位于其中,因此所有路径都应该以该文件夹名称为前缀)。

$ ls -la
total 29
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:28 ./
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:22 ../
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:29 .git/
-rw-r--r-- 1 tuoppi 197121  391 Sep  2 16:14 .project
drwxr-xr-x 1 tuoppi 197121    0 Sep  2 16:14 .settings/
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:26 bar/
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:26 common/
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:26 foo/
-rw-r--r-- 1 tuoppi 197121 1243 Sep  4 06:26 pom.xml
drwxr-xr-x 1 tuoppi 197121    0 Sep  4 06:28 somestuff/

git show c418c7d

commit c418c7d17ae70248e5e56a821b84ffaee6e8bdf5
Author: Your Name <you@example.com>
Date:   Mon Sep 4 06:23:21 2017 +0200

Initial commit

diff --git a/README.mf b/README.mf
new file mode 100644
index 0000000..e69de29

为什么git不会针对新文件路径重构这些提交?有没有争论呢?

0 个答案:

没有答案