內(nèi)網(wǎng)倉(cāng)庫(kù)和遠(yuǎn)端倉(cāng)庫(kù)關(guān)聯(lián)

一. why

項(xiàng)目需要用到github第三方庫(kù), 但是直接依賴github是有問(wèn)題, 第一有墻容易失敗, 第二github不可控(某天中美打架人家刪庫(kù))等, 所以需要在gitlab映射一份github的庫(kù).

二. 方案選擇

2.1 拷貝

先本地git clone github, 然后將特定分支(tag)代碼拷貝出來(lái), 推送到gitlab
優(yōu): 簡(jiǎn)單
劣: 丟失github本身的信息

2.2 同步

先本地git clone github, 然后添加gitlab的源, 并將github信息推送到gitlab
優(yōu): 保持和github同步
劣: 保留所有信息, 庫(kù)會(huì)大一點(diǎn)(冗余)

綜合來(lái)講: 還是第二種方案更好點(diǎn)

三. 實(shí)踐

  1. clone 源碼
    git clone https://github.com/**.git
  2. 查看源
    git remote -v
git remote -v
origin  https://github.com/google/double-conversion.git (fetch)
origin  https://github.com/google/double-conversion.git (push)
  1. 修改名稱
    git remote rename origin github
  2. 再次查看, 發(fā)現(xiàn)源從origin換成了github
git remote -v
github  https://github.com/boostorg/boost.git (fetch)
github  https://github.com/boostorg/boost.git (push)
  1. 添加gitlab源
    git remote add origin http://gitlab.**.git
  2. 再次查看
git remote -v
github  https://github.com/boostorg/boost.git (fetch)
github  https://github.com/boostorg/boost.git (push)
origin  http://gitlab.**.git (fetch)
origin  http://gitlab.**.git (push)
  1. 推送到gitlab
    git push origin master
  2. 同步tag
    git push origin --tags
  3. done
    去gitlab查看信息, 和github一致, 分支和tag都相同.
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容