所以需要在本地推送遠(yuǎn)程時(shí)同步到兩個(gè)不同的git遠(yuǎn)程倉(cāng)庫(kù)
在你的項(xiàng)目目錄下找到.git文件夾隐锭,如果沒(méi)有就需要查看顯示隱藏文件了。?
然后找到里面的config文件?
一般正常情況下config里面的內(nèi)容大概是這樣?jì)饍旱模?/p>
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@gitee.com:qiuzhongwei0519/HaveCar--ww-2.0.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
這個(gè)時(shí)候我們需要修改它计贰,讓它有除了orgin之外的另外一個(gè)遠(yuǎn)程倉(cāng)庫(kù)?
可以取名為“mirror”即鏡像倉(cāng)庫(kù)钦睡,我就把GitHub做為主要遠(yuǎn)程倉(cāng)庫(kù),git@oschina做為國(guó)內(nèi)鏡像倉(cāng)庫(kù)?
于是修改后的config文件如下所示:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@gitee.com:qiuzhongwei0519/HaveCar--ww-2.0.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
這個(gè)時(shí)候我們需要修改它躁倒,讓它有除了orgin之外的另外一個(gè)遠(yuǎn)程倉(cāng)庫(kù)?
可以取名為“mirror”即鏡像倉(cāng)庫(kù)荞怒,我就把GitHub做為主要遠(yuǎn)程倉(cāng)庫(kù)秧秉,git@oschina做為國(guó)內(nèi)鏡像倉(cāng)庫(kù)?
于是修改后的config文件如下所示:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@gitee.com:qiuzhongwei0519/HaveCar--ww-2.0.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "mirror"]
? ? url = git@git.oschina.net:hwangfantasy/beautify.git
? ? fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
remote = mirror
merge = refs/heads/master
2. pull操作
使用以下命令,可以分別從兩個(gè)遠(yuǎn)程倉(cāng)庫(kù)pull:
git pull origin master?
git pull mirror master
使用以下命令恋技,可以分別push到兩個(gè)遠(yuǎn)程倉(cāng)庫(kù):
git push origin master?
git push mirror master