bash Git - 在 github 上使用端口 9418 进行远程操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19023511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git - Use port 9418 for remote on github
提问by Rayjax
I am trying to connect to github at school but port 443 is blocked.
我试图在学校连接到 github,但端口 443 被阻止。
The admin told me to use port 9418 instead which I believe is the default port for the git protocol.
管理员告诉我改用端口 9418,我认为这是 git 协议的默认端口。
But in git bash (windows) if i try to do git remote set-url origin git://github.com/me/myrepo.git
and do a push, it tells me I can't push to this URL, and to use https://github...
instead.
但是在 git bash (windows) 中,如果我尝试执行 git remote set-url origingit://github.com/me/myrepo.git
并执行推送,它会告诉我我无法推送到此 URL,https://github...
而是使用它。
How can I configure git to use port 9418 ?
如何配置 git 以使用端口 9418 ?
回答by valodzka
From github documentation:
来自github 文档:
You can only push to one of two writeable protocol URL addresses. Those two include an SSH URL like [email protected]:user/repo.git or HTTPS URL like https://github.com/user/repo.git.
您只能推送到两个可写协议 URL 地址之一。这两个包括像 [email protected]:user/repo.git 这样的 SSH URL 或像https://github.com/user/repo.git这样的 HTTPS URL 。
So you need open port 22 or 443 to work, git protocol is read only.
所以你需要打开端口 22 或 443 才能工作,git 协议是只读的。
回答by hustljian
check : ReadyState4or git remote add with other ssh port
检查:ReadyState4或git remote add 与其他 ssh 端口
One way : git remote add origin ssh://[email protected]:<port>/<project name>
单程 : git remote add origin ssh://[email protected]:<port>/<project name>
Second way : change the .git/config
方法二:改变 .git/config
old:
老的:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:<project name>
new:
新的:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://[email protected]:<port>/<project name>