git修改遠程倉庫關聯

公司搬移, 做爲git倉庫的服務器IP地址變了。 本地代碼挺多,從新檢出太佔時間,能夠修改一個什麼配置讓我本地倉庫和新的遠程倉庫創建關聯嗎, 答案是確定的!git

方法有不少,這裏簡單介紹幾種:

如下均以項目git_test爲例: 
老地址:http://hostname/**/**.git
新地址:http://hostname/**/**.git
遠程倉庫名稱: originvim

方法一 經過命令直接修改遠程地址

  1. 進入git_test根目錄
  2. git remote 查看全部遠程倉庫, git remote xxx 查看指定遠程倉庫地址
  3. git remote set-url origin http://192.168.100.235:9797/john/git_test.git

方法二 經過命令先刪除再添加遠程倉庫

  1. 進入git_test根目錄
  2. git remote 查看全部遠程倉庫, git remote xxx 查看指定遠程倉庫地址
  3. git remote rm origin
  4. git remote add origin http://192.168.100.235:9797/john/git_test.git

方法三 直接修改配置文件

  1. 進入git_test/.git
  2. vim config 

    [core] 
    repositoryformatversion = 0 
    filemode = true 
    logallrefupdates = true 
    precomposeunicode = true 
    [remote "origin"] 
    url = http://192.168.100.235:9797/shimanqiang/assistant.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 
    [branch "master"] 
    remote = origin 
    merge = refs/heads/master
    服務器

    修改 [remote 「origin」]下面的url便可fetch

方法四 經過第三方git客戶端修改。

以SourceTree爲例,點擊 倉庫 -> 倉庫配置 -> 遠程倉庫 便可管理此項目中配置的全部遠程倉庫, 並且這個界面最下方還能夠點擊編輯配置文件,一樣能夠完成方法三。url

相關文章
相關標籤/搜索