Git遠程倉庫地址變更本地如何修改


公司搬移, 作為git倉庫的服務器IP地址變了。 本地代碼挺多,重新檢出太占時間,可以修改一個什么配置讓我本地倉庫和新的遠程倉庫建立關聯嗎, 答案是肯定的!

方法有很多,這里簡單介紹幾種:

以下均以項目git_test為例:
老地址:http://192.168.1.12:9797/john/git_test.git
新地址:http://192.168.100.235:9797/john/git_test.git
遠程倉庫名稱: origin

 

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

  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

  3. [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即可

  4. 方法四 通過第三方git客戶端修改。

  5. 以SourceTree為例,點擊 倉庫 -> 倉庫配置 -> 遠程倉庫 即可管理此項目中配置的所有遠程倉庫, 而且這個界面最下方還可以點擊編輯配置文件,同樣可以完成方法三。

原文鏈接:https://blog.csdn.net/asdfsfsdgdfgh/article/details/54981823


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM