我试图在Git中更改我的原始分支的远程URL.我想要改变的只是SSH端口.首先,列出我的远程起源给了我:
git remote -v origin user@example.com:package/name.git (fetch) origin user@example.com:package/name.git (push)
然后,我运行set-url
命令来更改我的原始URL:
git remote set-url origin ssh://user@example.com:XX/package/name.git (XX is my port #)
现在,我可以毫无问题地获取,但是将我的分支推送到原点不起作用,因为推送URL没有改变.再次列出我的遥控器我得到了这个:
git remote -v origin ssh://user@example.com:XX/package/name.git (fetch) origin user@example.com:package/name.git (push)
为什么我的set-url
命令只更改了获取URL?
来自git-remote
手册:
set-url Changes URL remote points to. Sets first URL remote points to matching regex(first URL if no is given) to . If doesn’t match any URL, error occurs and nothing is changed. With --push, push URLs are manipulated instead of fetch URLs.
所以你应该另外执行:
git remote set-url --push origin ssh://user@example.com:XX/package/name.git