2017-02-06 36 views
1

我在GitHub中有一個遠程回購,並且我在Heroku中擁有另一臺具有完全相同數據的遠程回購。我已經開始通過一種新設備進行工作,並試圖克隆兩種回購方式,但無法找到一種簡單的方法來實現。 git clone [repo name]創建一個新目錄。因此,從第二個repo克隆將會阻止它嘗試創建一個同名的新目錄。我可以克隆一個回購,cd到它,然後克隆第二個。但是,這樣做並不理想,因爲我最終會得到一個包含其他回購協議的回購協議。使用相同的數據克隆兩個遠程回購

例如,如果我的密碼是Repositories/,我爲GitHub做了git clone,那麼我最終會得到Repositories/MyProject。如果我然後cd到它並嘗試git clone第二回購我最終Repositories/MyProject/Myproject

+0

我編輯了我的答案 – VonC

回答

1

git的遠程添加[回購名]」創建一個新的目錄

不,它不需要。 git remote僅修改當前回購的本地配置(.git/config文件)。

git clone /url/first_repo 
cd first_repo 
git remote add second_repo /url/second_repo 
git config --local -l 
git fetch second_repo 

然後你就可以看到所有分支從兩個回購協議:

git branch -avv 

如果要克隆2個回購,簡單地從相同的根文件夾

cd afolder 
git clone /url/repo1 
git clone /url/repo2 adifferentName 
1

去做讓你Repositories/目錄。然後克隆第一個(git clone ...)。現在進入第一個回購並添加一個新的遠程(git remote add <second>)。

$ cd Repositories 
$ git clone <first-repo-url> 

$ cd <first-repo> 
$ git remote add <second> <second-repo-url> 
$ git pull second master   # pull the second repo's master branch changes