[英]Cannot clone git repo inside existing checked out git repository
我試圖將我的git存儲庫克隆到現有已檢出的git存儲庫中,並遇到此故障。 我之前已經完成了此工作流程,所以無法弄清楚為什么現在會失敗。 有沒有人有什么建議?
git存儲庫確實存在,我可以在其他位置將檢出的存儲庫外部克隆
假設我做了以下事情
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 REPO的子模塊添加。 我只是想弄清楚如何在git簽出的現有工作文件夾中克隆存儲庫。
看看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>
您將需要提交此更改以進行更新。
您的問題似乎有沖突。 如果不使用git子模塊AFAIK,則不能在另一個git repo中包含git repo。
您可以做的是擁有一個不是git repo的目錄,然后將兩個存儲庫都克隆到該目錄中(因此不要將存儲庫放在彼此之間)。
您還可以將存儲庫添加為遠程存儲庫(使用git remote add name_of_remote http://your/remote/here
)。 然后,您可以從同一存儲庫中的任一倉庫中檢出任何分支。
我通常不喜歡使用子模塊。 對於這種情況,我將執行以下操作:
1)在主倉庫中.gitignore要在其中存儲倉庫的文件夾路徑為cassandra-repo / *的路徑 (忽略它)
2)在終端中執行 git clone https://github.com/apache/cassandra.git path-of-cassandra-repo/
其中“ path-of-cassandra-repo /”您要git存儲的文件夾的名稱回購。
3)您准備就緒...編碼愉快。
讓我知道這是否適合您...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.