0

I am not able to push a local repository to a GitHub repo, both created at the same time.

The steps I took:

  1. In Visual Studio Code (VS Code) I select Open Folder to add the project folder.
  2. I click on the Source Control pane and then Initialise Repository.
  3. I Stage and Commit the files using the VS Code GUI.
  4. On GitHub online I create a New repository, naming it and not adding any other files (e.g. .gitignore).
  5. I copy from the GitHub instructions that appear and run the command in the VS Code terminal (git bash): git remote add origin https://github.com/username/reponame.git
  6. I then try to Publish Branch via VS Code GUI, or run the code in the VS Code terminal from GitHub: git push -u origin main, BUT both fail and produce the error that follows:
# GIT ERROR

> git push origin main
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date
# TERMINAL OUTPUT

$ git push -u origin main
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 8 threads
Compressing objects: 100% (44/44), done.
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (45/45), 151.59 MiB | 10.27 MiB/s, done.
Total 45 (delta 5), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

I've deleted the local .git folder and the GitHub repo and tried multiple times, but can't get it to work. I appreciate any help.

Buzz B
  • 75
  • 7
  • git finished its job successfully with using HTTP/1.1 protocol after the failed attempt to use HTTP/2 protocol. It's better to use SSH protocol in the origin URL git://github.com:username/reponame.git – 273K Jan 09 '23 at 15:25
  • @273K I get the error `error: remote origin already exists.` when I run: `git remote add origin git@github.com:username/reponame.git`. Should I delete the local `.git` and GitHub repo and try again? – Buzz B Jan 09 '23 at 15:45
  • 1
    See https://stackoverflow.com/questions/2432764/how-do-i-change-the-uri-url-for-a-remote-git-repository – 273K Jan 09 '23 at 15:53
  • @273K It says that I don't have permissions to push to the repo. I also says: `The authenticity of host 'github.com (140.82.121.3)' can't be established.` I said to connect anyway, but then: `git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.`. It also gave the warning `Permanently added 'github.com' to the list of known hosts.`, if I wanted to undo that how do I go about that? – Buzz B Jan 09 '23 at 16:01
  • 1
    You need to configure ssh access on github https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent – 273K Jan 09 '23 at 16:07
  • @273K thank you, I have manged to get it to work, I used this answer `git config --global http.postBuffer 524288000` from the link in the first comment and then removed the file from my local repository that exceeded 100MB, before continuing as normal. Would you like to post it as an answer for me to accept? If not, then I could do so later on to close this question. Thanks again. – Buzz B Jan 09 '23 at 16:34

0 Answers0