Skip to content

Instantly share code, notes, and snippets.

@fokayx
Last active February 23, 2024 09:52
Show Gist options
  • Star 56 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save fokayx/255b228ded2bca1c4f60 to your computer and use it in GitHub Desktop.
Save fokayx/255b228ded2bca1c4f60 to your computer and use it in GitHub Desktop.
Git switch remote URLs. Git 更換遠端伺服器倉庫網址

Git 更換遠端伺服器倉庫網址URL

1.確認目前Git遠端伺服器網址: git remote -v

git remote -v
origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
origin  https://github.com/USERNAME/REPOSITORY.git (push)

2.更換Git遠端伺服器位網址,使用:git remote set-url

git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git

3.再次確認Git遠端伺服器網址

git remote -v
origin  https://github.com/USERNAME/OTHERREPOSITORY.git (fetch)
origin  https://github.com/USERNAME/OTHERREPOSITORY.git (push)

如果是使用SSH的存取網址,指令一樣是使用git remote set-url,再接上新的SSH URL就可以更換,指令如下:

git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git

不管是要HTTP/HTTPS跟SSH,二種存取網址都是可以直接做更換,然後下次git push/ git fetch 就會到新設定的網址去了唷。

@dq042000
Copy link

謝啦

Copy link

ghost commented Aug 14, 2021

感謝!

@Noelhsiao
Copy link

感謝!

@dickstar
Copy link

謝謝你

@maninthemirror
Copy link

謝謝菩薩

@Gaseik
Copy link

Gaseik commented Sep 7, 2021

感謝分享

@bluehomewu
Copy link

感謝支援!

@Linvay
Copy link

Linvay commented Nov 3, 2021

十分感謝!

@siuoly
Copy link

siuoly commented Nov 15, 2021

謝謝了

@ParinLL
Copy link

ParinLL commented Dec 22, 2021

感謝支援!

@momolly1024
Copy link

感謝~~

@music87
Copy link

music87 commented Sep 3, 2022

謝謝!

@aki168
Copy link

aki168 commented Oct 25, 2022

謝謝!!

@rhhuangd
Copy link

rhhuangd commented Nov 4, 2022

讚 推

@ParinLL
Copy link

ParinLL commented Dec 1, 2022

感謝!

@x16472
Copy link

x16472 commented Dec 28, 2022

謝謝!

@TimWang95
Copy link

感謝 !!

@Russ420
Copy link

Russ420 commented Jan 16, 2024

大感謝!

@qw123opl
Copy link

感恩~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment