Home > OS >  Novice GitHub question. No ssh problem; how to push a file?
Novice GitHub question. No ssh problem; how to push a file?

Time:09-26

Good morning, after 4 useless hours of tutorial on the Net, I'm asking my question here.

  1. I've created my SSH key and added it to Github
  2. Then I've created a Repository called "Repo" on GitHub.com
  3. Then I've created a folder called "Repo" on my computer and I've initialized git as usual : git.init etc...
  4. But then if I want to push something, let's say the README.md, after :
git add README.md
git commit README.md

git status returns "On the main branch Your branch is in advance of 3 commits upon 'origin/main' (Use "git push" to publish these local commits) Nothing to valid, the copy of your work is clean"

But when I write :

git push README.md

I get

"Please make sure you have the correct access rights and the repository exists"

So, what's the explanation ? ssh -T [email protected] returns : "Hi Aurelien! You've successfully authenticated, but GitHub does not provide shell access." So I don't understand at all the problem.

EDIT : git remote -v returns :

origin  [email protected]:Aurelien/Repo.git (fetch)
origin  [email protected]:Aurelien/Repo.git (push)

CodePudding user response:

The problem you're seeing is that you're writing git push README.md. git push takes a remote name or URL, so what you're asking Git to do is to push to the local repository called README.md. However, since that's a file, not a Git repository, it doesn't work.

When you want to push, write git push origin, or, assuming the branch you want to push is called main, git push origin main. Note that this will push the entire history of your branch, not just the one file. Git doesn't provide a way to push just one file; instead, it pushes a commit and the history leading up to it.

  • Related