2011-01-27 102 views
31

我已經使用git clone從服務器克隆了一個項目,現在我想將它複製到另一臺服務器,以便其他人可以開始使用它。我想我可以簡單地手動複製整個存儲庫,然後發出git config --bool core.bare true並刪除除.git文件夾以外的所有文件夾,但我認爲這不符合「裸露」存儲庫的要求,而且我擔心它可能會給我帶來問題。在遠程服務器上創建本地git存儲庫副本

我希望我可以使用git init --bare創建新的遠程存儲庫,只需將我的本地一個存儲到它,但由於我最初從另一個服務器克隆我的本地副本,origin似乎阻止我這樣做。

回答

43
  1. 在服務器上創建一個新的純倉庫:
    git init --bare newrepo.git
  2. 添加它作爲一個遠程在本地回購:
    git remote add newrepo git://[email protected]/newrepo.git
  3. git push newrepo master推特定分支,或者
    git push --all newrepo推所有分支
+7

`git push --all newrepo`應該這樣做。 – 2011-01-27 18:12:36

14

另一種方法是(如你所願):

git clone --bare /path/to/repo newrepo.git 
相關問題