Can't push to new repo?

Should it not ask for username / password as a default? No documentation!!!
Constantly getting “Please make sure you have the correct access rights
and the repository exists.” error from the terminal. Tried it with GitHub Desktop the same.

Git ships with a credential manager, so you should be asked user and password only once. Depending on your OS, things might be slightly different (e.g. under Windows you’re better off installing MS credentials manager).

If you are using multiple accounts (e.g. GitHub, GitLab, Bitbucket, etc.) there’s the possibility that Git is trying to use your default account (it happened to me in some cases). It’s hard to tell without more info about the repository.

Make sure you’ve trying to push to a repository you own (i.e. in case you forked a repository, that you’ve cloned locally the fork, not the upstream original repository), and that you’re pushing to your fork (not the upstream).

When you’re in the terminal, inside the repository, you might want to check that the remotes are correctly set:

git remote -v

the above command will list which remotes are set on the repository, and where push and pull operations are going to be done for each branch.

Thank you!
I’m on mac and followed steps. However the initial push went wrong and would not ask for credentials and still doesn’t. Where do I set these credential?

So I created the original repo again to try to push and here is what I have on my terminal following your remote -v command. And still the same as you see. Cannot push. Thanks

Cems-MBP:react-rmdb cemcelik$ git remote -v

origin :cemceliks/react-rmdb-deploytest.git (fetch)

origin :cemceliks/react-rmdb-deploytest.git (push)

Cems-MBP:react-rmdb cemcelik$ git remote add origin /cemceliks/react-rmdb-deploytest.git

fatal: remote origin already exists.

Cems-MBP:react-rmdb cemcelik$ git push -u origin master

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.

Cems-MBP:react-rmdb cemcelik$

The URLs in the git remote output look edited, but the git push output clearly shows you’re using SSH. In that case git will never ask for credentials, it will try to use whatever keys SSH has available. So you either haven’t set up SSH correctly, or the key you have isn’t on your Github account.

Have a look at the documentation for Connecting to GitHub with SSH to see how to fix those problems.

Thank you i think it may be set up automatically by VS code by default. I have disabled git in VS code now. Better to start again. I will look into SSH as well. I haven’t set it up yet.

It might be an idea to see if there are any logged issues with VSCode out of the box.

Thanks again
Cem

1 Like

There seem to be multiple problems here.

  1. the remotes don’t have a protocol! it should show something like:

    origin  https://github.com/cemceliks/react-rmdb-deploytest.git (fetch)
    
  2. The repository on GitHub is empty! i.e. when you created it you didn’t add a README.md file, a .gitignore or a license file when asked; which means that there are no commits for you to pull (basically, the repository doesn’t really exist, it’s just a placeholder waiting for the first commit).

You’ll have to initialize the repository locally, populate it and create a first commit, then push to origin.

Make sure to fix the remotes so that you include a protocol (https or SSH, whichever one you’re using). You’ll have to delete the current remote first, or you’ll get the “remote origin already exists” message).

Regarding the use of SSH, it requires a bit more setup work (like @airtower-luna mentioned). You might start off using https, just to get the repository up and going, and you can always switch to SSH later.

That’s not necessary, you can use git remote set-url to change the URL of an existing remote.

Also when posting things like error messages it’s best to wrap them in triple backticks (```) so the forum doesn’t reformat them.

1 Like

Thank you, then how can I turn off SSH. I would rather start simple. Thank you. All very helpful :slight_smile:

Cem