0

I am trying to set up to build my first website and have been following an online tutorial. When trying to link visual studio and my GitHub repository, this is the message I get:

`

samanthacanela@samanthas-air Canela Street Art % git commit -m "initialized git repository"
[main 3a08e0a] initialized git repository
 2 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 about.html
 rename homepage.html => home.html (100%)
samanthacanela@samanthas-air Canela Street Art % git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

samanthacanela@samanthas-air Canela Street Art % git push --set-upstream origin main
The authenticity of host 'github.com (140.82.112.3)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
samanthacanela@samanthas-air Canela Street Art % 

`

I'm an absolute beginner. What the hell am I doing wrong?

I was following along a tutorial and they lost me.

1 Answers1

0

Based on my understanding, I can see that you may haven't setup the origin remote URI. To fix that issue, you'll need to follow these steps.

Logging into git (If you aren't already)

Run these commands to set your display name and email when pushing:-

$ git config --global user.name "Your name here"
$ git config --global user.email "your_email@example.com"

Using HTTPS access method (recommended)

Using GitHub CLI, you can run $ git auth login and follow the steps to login.

Or if you're using GCM (Git Credential Manager)* refer to this article by GitHub

* GCM is another way to store your credentials securely and connect to GitHub over HTTPS. With GCM, you don't have to manually create and store a personal access token, as GCM manages authentication on your behalf, including 2FA (two-factor authentication).

Using SSH access method

If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub. For more information, see "Generating a new SSH key."

Setting up your repository

** Make sure to run these commands inside your git environment and not globally.

#Set a new remote

git remote add origin github.com/example/example.git


#Verify new remote

git remote -v

Basically, a common cause for an error after following these steps is cloning using HTTPS method instead of SSH. You can correct this by going to your repository, clicking "Clone or download", then clicking the "Use SSH" button above the URL field and updating the URL of your origin remote like this:

$ git remote set-url origin git@github.com:ex-user/example.git

And that forces the source to be SSH.

If this still gives you an error, please refer to this answer.

For more help, refer to this document.

Aly Mobarak
  • 356
  • 2
  • 17