本地git倉庫關(guān)聯(lián)多個(gè)遠(yuǎn)程倉庫地址

工作中遇到一個(gè)不方便的地方。已經(jīng)擁有一套腳手架/工具庫項(xiàng)目,且在工作中不斷迭代更新,需要保持在公司遠(yuǎn)程倉庫,以及自己私有庫同步更新的話,同一套代碼,同步比較麻煩

讓一個(gè)本地倉庫同時(shí)關(guān)聯(lián)多個(gè)遠(yuǎn)程倉庫,可以同時(shí)push到不同的遠(yuǎn)程倉庫中

比如push到github和gitee,甚至自己的verdaccio庫

首先,查看

$ git remote -v
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (fetch)
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (push)

然后

$ git remote add gitee https://gitee.com/kilims-tech/react-mobile-seeds.git

當(dāng)初始化的時(shí)候,這個(gè)命令里的giteeorigin,相當(dāng)于命名了一個(gè)遠(yuǎn)程倉庫

此時(shí)再跑remove -v

$ git remote -v
gitee   https://gitee.com/kilims-tech/react-mobile-seeds.git (fetch)
gitee   https://gitee.com/kilims-tech/react-mobile-seeds.git (push)
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (fetch)
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (push)

如要push更新,可以:

$ git push -u gitee master // 到gitee
$ git push -u origin master // 到origin

Done

后續(xù),如果遠(yuǎn)程倉庫多起來,可以:

$ git remote set-url --add origin https://gitee.com/kilims-tech/react-mobile-seeds.git

此時(shí)再跑remove -v

$ git remote -v
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (fetch)
origin  http://xx.xx.xx.xx/Kilims/react-mobile-seeds.git (push)
origin  https://gitee.com/kilims-tech/react-mobile-seeds.git (push)

這樣子可以一次push到多個(gè)倉庫了

最后編輯于
?著作權(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)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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