我正在尝试将我的 git 存储库克隆到现有已 checkout 的 git 存储库中,但失败了。我以前做过这个工作流程,所以我不知道为什么现在会失败。有人有什么建议吗?
git 存储库确实存在,我可以在不同位置的 checkout 存储库之外克隆
假设我执行以下操作
1. cd <existing git repo clone folder>
2. git clone https://github.com/apache/cassandra
Cloning Git Repository of cassandra
Cloning into 'cassandra'...
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
什么可能导致此错误?
请注意 - 我不想将此存储库作为子模块添加到我的父 GIT 存储库中。我只是想弄清楚如何在从 git checkout 的现有工作文件夹中克隆存储库。
最佳答案
看看 git submodules
这正是为此而设计的。您可以在此处找到信息和示例:https://git-scm.com/book/en/v2/Git-Tools-Submodules
在您的情况下,这可能有效:
git submodule add https://github.com/apache/cassandra
为了更改子模块以跟踪特定的提交更改目录到子模块文件夹并正常切换分支。
cd submodule
git checkout -b some_branch origin/some_branch
或者对于一些特定的标签
git checkout <version_tag>
您需要提交此更改才能更新。
关于linux - 无法在现有 checkout 的 git 存储库中克隆 git repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38400005/