7

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 ?

3
  • For git protocol, the default port is 9418
    – Shunya
    Sep 26, 2013 at 8:59
  • 4
    tell your school IT to open port 443. from a security perspective, your school should allow https:// ("secure", that is "encrypted", http) rather than most other ports (including http)
    – umläute
    Sep 26, 2013 at 9:36
  • Brief note, even if late: "it tells me I can't push" The git:// protocol is anonymous and can only be used for fetching, cloning, etc., i.e. downloads. You cannot git push to any remote via the git:// protocol because of this. I add this b/c the accepted answer does not explain why this works this way.
    – code_dredd
    Oct 30, 2019 at 18:31

4 Answers 4

8

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.

3
  • if port 22 it open - set origin to git@github.com:me/myrepo.git
    – valodzka
    Sep 26, 2013 at 10:27
  • connect to host github.com port 22: Bad file number fatal: could not read from remote repository. Please make sure you have the correct access rights and the repository exists
    – Rayjax
    Sep 26, 2013 at 11:16
  • You probably configured something incorrectly or port 22 is closed
    – valodzka
    Sep 26, 2013 at 11:54
6

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>
0

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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.