Git提交到多個遠程倉庫

知識拓展
顯示所有遠程倉庫
$ git remote -v

顯示某個遠程倉庫的信息
$ git remote show [remote]

增加一個新的遠程倉庫,並命名
$ git remote add [shortname] [url]

例如我有下面兩個倉庫:
https://gitee.com/obear/test.git
https://github.com/obear/test.git

先添加第一個倉庫:
git remote add origin https://gitee.com/obear/test.git
再添加第二個倉庫:
git remote set-url --add origin https://github.com/obear/test.git

如果還有其他,則可以像添加第二個一樣繼續添加其他倉庫。

然後使用下面命令提交:
git push origin --all

打開.git/config,可以看到這樣的配置:

[remote "origin"]
    url = https://github.com/obear/test.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://gitee.com/obear/test.git

剛纔的命令其實就是添加了這些配置。如果不想用命令行,可以直接編輯該文件,添加對應的url即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章