-1

I have created a Github repository and I'm trying to add a simple text file to that repository.

This file is inside a folder with the same name of the repository.

This is the first time I'm using Github and I've searched other similar questions but couldn't find an answer.

So, using Git bash, I navigate to the folder and type:

git add texto.txt
git commit -m "first commit"
git push origin master

But the file is not uploaded, and I see the error:

git@github.com: Permission denied (public key) 
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I have created a SSH/RSA key in my PC here:

C:/Users/xxxxxx/.ssh/id_rsa

I know this should be simple, but for sure I'm doing something wrong here..

  • 1
    `git add` only tells git to add the file to the staging area. Next thing for you to do is create a commit `git commit -m 'first commit'` and then push it to the server `git push origin master`, assuming you have configured your remote. – Paolo Dec 25 '19 at 16:05
  • My issue seems to be related to the SSH key, please see my edited question above, thanks a lot for helping! –  Dec 25 '19 at 16:14
  • Does this answer your question? [git push: permission denied (public key)](https://stackoverflow.com/questions/19660744/git-push-permission-denied-public-key) – phd Dec 25 '19 at 17:52
  • https://stackoverflow.com/search?q=%5Bgit%5D+Permission+denied+public+key – phd Dec 25 '19 at 17:52

1 Answers1

0

Git add is the first step to make Git aware of a file.

Your next step is to git commit to create a snapshot of your files (your commit can contain multiple changes you added)

The final step is to git push the changes to github.

The add makes git aware of your changes. commit bundles one or more changes into a snapshot. push pushes one or more commits to another git repository.

I highly recommend going through a getting started tutorial:

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • thanks a lot for helping, I'm sure to read those tutorials. My issue seems to be related to the SSH key, please see my edited question above. –  Dec 25 '19 at 16:13
  • 1
    I'd start out with a `https` clone, it's easier to get going, you can switch to 'ssh' at any time anyway. If you want to do `ssh`, make sure you register the key under yur account on GitHub: https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account – jessehouwing Dec 25 '19 at 16:16
  • Ok, added the key, now I get the error ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:nunon/Algoritmos.git' I'll add a new question, thanks for helping! –  Dec 25 '19 at 16:23