我正在尝试使用 git subtree add
将一个名为 cow 的仓库添加到我的项目中。特别地,我想要添加分支 stable
(而不是 master
分支)。我尝试了:
git subtree add -P cow https://github.com/geoffryan/cow.git stable
但是这会返回错误
'stable' does not refer to a commit.
我也尝试过:
git subtree add -P cow https://github.com/geoffryan/cow.git cow/stable
'cow/stable' does not refer to a commit.
并且:
git subtree add -P cow https://github.com/geoffryan/cow.git ca26d248a12c21264e32a2c212381cafb578c9fb
'ca26d248a12c21264e32a2c212381cafb578c9fb' does not refer to a commit.
哈希值是指stable
分支中最新提交的哈希值。我在网上看到的使用示例都使用master
作为提交,是否可以在非master
分支上使用subtree add
?
--squash
选项,这样 git subtree 就只会从子项目中导入单个提交,而不是其整个历史记录。 - Sebastien Varrette--squash
不是正确的选项,因为如果你使用git subtree
,通常你会想保留原始历史记录,否则你可以像往常一样复制和提交文件。 - gipi