2016/11/02

建立 mirror 的 Git Repo





《時 機》


Repo 架在甲地,但為了本地方便存取,須另架一個 mirror 的 Repo。
這個 local 的 Repo 只用來看 codes, log, branch info ....,不在其上修正.




《指 令》
以下動作是在 CentOS 6.5 上進行

1. cd 到你準備放 Mirror  Repo 的目錄
% cd /somewhere

2. 在本地創建一個空的 Repo
/somewhere % git init --bare Mirrored.git

3. 進到新建的 Repo
/somewhere % cd Mirrored.git

4. 建出 git repo 必要的目錄、檔案
/somewhere/Mirrored.git % git update-server-info
/somewhere/Mirrored.git % ls -F
branches/  config  description  FETCH_HEAD  HEAD  hooks/  info/  objects/  refs/  sync.log

5. 若是使用 apache 來存取 git repo,
/somewhere/Mirrored.git % sudo chown -R apache.apache . 

接著,準備mirror 甲地的 Repo

6. 到另一處工作目錄
% cd ~/tmp

7. 抓甲地的 Repo
~/tmp % git clone http://path-to-repo/mirroring.git
~/tmp % cd mirroring.git
~/tmp/mirroring.git %

8. 設定新的遠端 git repo 位置
~/tmp/mirroring.git % git remote set-url --push origin http://patch-to-repo/mirrored.git

9. local 更新 remote branch,因為是新的 repo,就是將本地的 origin/xxx 都刪
 ~/tmp/mirroring.git % git fetch --prune origin

 10. 將整包 push 上去
 ~/tmp/mirroring.git % gitpush --mirror












沒有留言:

張貼留言