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 ?

Rayjax
  • 7,494
  • 11
  • 56
  • 82
  • For git protocol, the default port is 9418 – Shunya Sep 26 '13 at 08: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 '13 at 09: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 '19 at 18:31

4 Answers4

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.

valodzka
  • 5,535
  • 4
  • 39
  • 50
  • if port 22 it open - set origin to git@github.com:me/myrepo.git – valodzka Sep 26 '13 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 '13 at 11:16
  • You probably configured something incorrectly or port 22 is closed – valodzka Sep 26 '13 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>
Community
  • 1
  • 1
hustljian
  • 965
  • 12
  • 9
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
Kumar Pankaj Dubey
  • 1,541
  • 3
  • 17
  • 17
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.

Dolphin
  • 29,069
  • 61
  • 260
  • 539