1
我想在本地git倉庫上執行備份到我的git服務器上的另一個位置。我見過很多關於將github備份到雲端的文章和文章,以及githu在本地備份的github repos。在這裏,我只是試圖將本地服務器git repo備份到服務器上的另一個位置。這是一個unix服務器。本地github備份
我想在本地git倉庫上執行備份到我的git服務器上的另一個位置。我見過很多關於將github備份到雲端的文章和文章,以及githu在本地備份的github repos。在這裏,我只是試圖將本地服務器git repo備份到服務器上的另一個位置。這是一個unix服務器。本地github備份
使用本地克隆與使用遠程克隆非常相似。作爲這種「遙控器」的「網址」,您可以使用文件系統路徑。
假設您的項目位於/path/to/repo1
,並且您想要在/backups
下創建備份。
下面是做這件事:
cd /path/to/repo1
git clone --bare . /backups/repo1.git
git add remote backup /backups/repo1.git
git push backup
這就造成在/backups/repo1.git
純倉庫這是原來的完美克隆。您可以更新與備份:
cd /path/to/repo1
git push backup
但是,由於原來的倉庫是其備份的「感知」,當你做一個git branch -r
,它會顯示在backup
遙控器,可能是太多重複的分支混亂。
另一種方式:
git init --bare /backups/repo1.git
cd /backups/repo1.git
git remote add origin /path/to/repo1
git remote update
這種方式備份意識到原來的回購,而不是周圍的其他方式。您可以使用以下方式更新備份:
cd /backups/repo1.git
git remote update
您遇到的問題是什麼? – Chris