简体   繁体   中英

Git - Use port 9418 for remote on github

I am trying to connect to github at school but port 443 is blocked.

The admin told me to use port 9418 instead which I believe is the default port for the git protocol.

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.

How can I configure git to use port 9418?

From github documentation :

You can only push to one of two writeable protocol URL addresses. Those two include an SSH URL like git@github.com:user/repo.git or HTTPS URL like https://github.com/user/repo.git .

So you need open port 22 or 443 to work, git protocol is read only.

check : ReadyState4 or git remote add with other ssh port

One way : git remote add origin ssh://git@domain.com:<port>/<project name>


Second way : change the .git/config

old:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@domain.com:<project name>

new:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://git@domain.com:<port>/<project name>

try this, it"ll ease your life

sed -i '/npm install/i \
RUN git config --global url."git@github.com:org".insteadOf 
"git://github.com/org" \
' Dockerfile

from this blog: https://github.blog/2021-09-01-improving-git-protocol-security-github/ , github did not support git protocol anymore.

On the Git protocol side, unencrypted git:// offers no integrity or authentication, making it subject to tampering. We expect very few people are still using this protocol, especially given that you can't push (it's read-only on GitHub). We'll be disabling support for this protocol.

you should change the protocol with ssh or https .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM