Try   HackMD

忽然接到要求要我們先將 remote 的網址切換到暫時的網址,原本想撐到他們修好的,不過我今天要上 code 不改不行。

顯示遠端

開始前先來看看原本的遠端版本庫:

$ git remote -v origin https://my.git.com:port/user_name/project.git/ (fetch) origin https://my.git.com:port/user_name/project.git/ (push)

更改 config

同仁給我的方法是直接修改 config 檔案。

$ cd project_folder $ vim .git/config

檔案內容長這樣:

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = https://my.git.com:port/user_name/project.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master

直接把檔案中 url 換成新的 https://my.tmp-git.com:port/user_name/project.git

git 指令

不過我覺得應該有 git 的指令可以更改才對,所以查了下指令:

$ git remote set-url origin https://my.tmp-git.com:port/user_name/project.git

參考資料

  1. fokayx (2015-04-12)。Git更換遠端伺服器倉庫網址 。檢自 fokayx’s gists (2019-01-04)。

更新紀錄

最後更新日期:2020-12-23
  • 2020-12-23 發布
  • 2020-09-18 完稿
  • 2020-09-18 起稿



本文作者: 辛西亞.Cynthia
本文連結辛西亞的技能樹 / hackmd 版本
版權聲明: 部落格中所有文章,均採用 姓名標示-非商業性-相同方式分享 4.0 國際 (CC BY-NC-SA 4.0) 許可協議。轉載請標明作者、連結與出處!