1

I am getting quite desperate. I am a beginner in GIT. I am trying to create a new repository by the GitHub guideline:

echo "<MY_TAG>" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin <MY_SSH>
git push -u origin main

For some reason, after writing "git push -u origin main", nothing happens. After some time, it stops and shows an error:

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have no idea why. I did the same thing just a few hours ago without any problem.

adler
  • 61
  • 8
  • Double-check what you put in `` (remote repo link) then your rights to the repo. – Romain Valeri Oct 24 '21 at 11:23
  • I created a new repository on GitHub and just copied it. How can I check my rights? And how to change them? – adler Oct 24 '21 at 11:26
  • 1
    To clarify, it's not "nothing happens". It's just git is trying to connect to your remote repo, and then timing out after some time, then finally showing you that message. You can see more of what it's doing by adding [`GIT_TRACE=1` or `--verbose`](https://stackoverflow.com/q/7319357/2745495). Check your repo URL (`git remote -v`) if it's correct and your internet connection. – Gino Mempin Oct 24 '21 at 11:26
  • Does this answer your question? [ssh: connect to host github.com port 22: Connection timed out](https://stackoverflow.com/questions/15589682/ssh-connect-to-host-github-com-port-22-connection-timed-out) – Gino Mempin Oct 24 '21 at 11:28
  • I just added "-v" to the command and it worked just fine. Now I am confused even more. – adler Oct 24 '21 at 11:30
  • By "worked fine" you mean the push was successful? The `-v` shouldn't have fixed it, it's just for more logs. I say it was probably was just a glitch in your network connection. – Gino Mempin Oct 24 '21 at 11:32
  • 1
    That's the reason why I was confused. So most likely I just had a problem with a network connection. – adler Oct 24 '21 at 11:35

1 Answers1

1

You can also switch, for testing, to an HTTPS URL and see if the issue persists.

cd /path/to/repo
git remote set-url origin https://github.com/<me>/<myRepo>

git push -u origin main

Make sure through that github.com is reachable in the first place (no matter the protocol)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250