公司搬移, 作為git倉庫的服務(wù)器IP地址變了碳胳。 本地代碼挺多勇蝙,重新檢出太占時(shí)間,可以修改一個(gè)什么配置讓我本地倉庫和新的遠(yuǎn)程倉庫建立關(guān)聯(lián)嗎挨约, 答案是肯定的味混!
方法有很多产雹,這里簡單介紹幾種:
以下均以項(xiàng)目test為例:
老地址:http://192.168.2.22:9797/john/test.git
新地址:http://192.168.100.235:9797/john/test.git
遠(yuǎn)程倉庫名稱: origin
方法一 通過命令直接修改遠(yuǎn)程地址
進(jìn)入test根目錄
git remote 查看所有遠(yuǎn)程倉庫
git remote xxx 查看指定遠(yuǎn)程倉庫地址
git remote set-url origin http://192.168.100.235:9797/john/test.git
方法二 通過命令先刪除再添加遠(yuǎn)程倉庫
進(jìn)入git_test根目錄
git remote 查看所有遠(yuǎn)程倉庫
git remote xxx 查看指定遠(yuǎn)程倉庫地址
git remote rm origin
git remote add origin http://192.168.100.235:9797/john/test.git
方法三 直接修改配置文件
進(jìn)入test/.git
vim config
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = http://192.168.100.235:9797/john/test.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
修改 [remote “origin”]下面的url即可
方法四 通過第三方git客戶端修改。
以SourceTree為例翁锡,點(diǎn)擊 倉庫 -> 倉庫配置 -> 遠(yuǎn)程倉庫 即可管理此項(xiàng)目中配置的所有遠(yuǎn)程倉庫蔓挖, 而且這個(gè)界面最下方還可以點(diǎn)擊編輯配置文件,同樣可以完成方法三馆衔。