我有這個設定
machineA -> remote server with a repo.git initialized with --bare
machineB -> client that can access to internet and clone repo.git, so it locally will have repo
machineC -> connected in LAN with machineB and no internet access
目標是使 machineC 與 machineB 存盤庫一起作業(以只讀模式),就好像它是遠程存盤庫一樣。因此,machineB 會定期從遠程服務器執行 git fetch
我通過 SMB 共享本地 machineB 存盤庫,并且能夠從 machineC 克隆它。
問題是我只能獲得 master 分支或只有 machineB 上的本地分支,而不是 machineA 上存在的所有分支。
是否有任何命令可以在本地獲取所有內容或將 repo 轉換為 .git ?
干杯
uj5u.com熱心網友回復:
在 machineB 中,從 machineA 進行鏡像克隆
git clone --mirror /url/to/machineA/repository
在 machineC 中,從 machineB 中的鏡像倉庫克隆
git clone /url/to/machineB/repository
當 machineC 倉庫需要 machineA 的最新資料時,首先更新 machineB 中的鏡像倉庫
git remote update
然后更新 machineC 中的存盤庫
git fetch
問題是我只能獲得 master 分支或只有 machineB 上的本地分支,而不是 machineA 上存在的所有分支。
在您當前的情況下,您仍然可以通過以下方式獲取 machineC 存盤庫中的所有分支和標簽
git fetch origin refs/remotes/origin/*:refs/remotes/origin/* refs/tags/*:refs/tags/*
但這是不自然的和令人困惑的。通過將 machineB 存盤庫從非裸存盤庫轉換為鏡像存盤庫,我們可以在 machineC 存盤庫中使用熟悉的命令。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/484661.html
下一篇:如何有條件地運行gitpush
