Using git to push to github - current branch has no upstream then shh error

21 Views Asked by At

I've pushed from git to github on this ssh/set up before. IT HAS WORKED.

I created a new repo on github. I set up remote - when I type git remote -v it gives back two lines starting with "origin" that have the (fetch) and (push) addresses. They're both correct, correct username and spelling.

If I type

git add .
git commit -m "initial commit"
git push

I get "fatal: the current branch main has no upstream branch. To push..."

so I try the following command it suggests (I type it exactly, maybe I need to change a bit?)

git push --set-upstream origin main

Then it says: "ssh: Could not resolve hostname github: Name or service unknown /n fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repo exists"

So I check git remote -v

It has the correct name and the ssh definitely works - I used it yesterday. I've tried re-creating the repo and changing the remote already but that didn't help.

What is wrong? What can I try next? Thanks!

0

There are 0 best solutions below