0

I have a problem similar to the question in this link but when I try the solutions on my side it doesn't work.

I created a new project named "example1". Then I create a repository on GitHub named "example1".

After committing all changes, I ran

git push origin master

and came across this message:

$ git push origin master
ssh: Could not resolve hostname github.com:Sidney-Dev: Name or service not 
known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Then I added this command:

git remote add origin ssh://git@github.com:Example-Dev/example1.git

And then checked:

$ git remote -v
origin  ssh://git@github.com:Sidney-Dev/laravelblog.git (fetch)
origin  ssh://git@github.com:Sidney-Dev/laravelblog.git (push)

But when I try to do git push again, I still come across the same errors as mentioned above.

How can I push my code to the GitHub repository?

Sidney Sousa
  • 3,378
  • 11
  • 48
  • 99

3 Answers3

1

first, remove your origin:

git remote remove origin

then add it again...but without ssh://

git remote add origin git@github.com:Example-Dev/example1.git

You can copy the commands right from the gh initialization page.

Or you can read this: git ssh protocol

I guess it expects a port after : when you use the URL scheme

Benni
  • 69
  • 1
  • 4
0

The correct syntax for the ssh remote URL is either

git@github.com:Sidney-Dev/laravelblog.git

or

ssh://git@github.com/Sidney-Dev/laravelblog.git

Please note slash instead of colon.

phd
  • 82,685
  • 13
  • 120
  • 165
  • @php So I first used git remote remove command...then used this: git remote add origin git@github.com:Sidney-Dev/laravelblog.git. when I run "git push origin master" it says that my current branch is behind, but when I run "git pull remote master" or "git pull" it says that my baccess rights are not correct, which is the same error I was getting. – Sidney Sousa Feb 06 '19 at 22:08
  • *current branch is behind* and *access rights are not correct* are different problems. Your initial problem with incorrect ssh URL syntax is now fixed, as for the other problems you better ask new questions. – phd Feb 06 '19 at 22:25
-1

You may have to manually go to the github website and create the repository, then do git pull on your master branch and open the project through git bash.

Zach Pedigo
  • 396
  • 2
  • 9