0

I created a private repo on github and tried to set it up as my remote of a local git repository. However, when the remote is set to the default https address (https://github.com/...), using git push gives me error "Error: Repository not found". After googling around, I tried using (https://username@github.com/...), but that gave me "Failed to connect to gitHub.com port 443 : Connection Refused."

So finally I tried using the ssh method, which works, after setting up the ssh key and stuff. So what was I doing wrong with the https setup? I didn't have this kind of problem with public repos.

Edmonds Karp
  • 155
  • 9
  • I suspect you've got a local git setup that attempts to automatically authenticate with a saved username and password instead of prompting you for one. Pushing over HTTP typically requires you to type your username and password, so if you're not getting those prompts, then you have an authentication problem. – merlin2011 Feb 11 '18 at 23:52
  • You can try https://stackoverflow.com/a/64587959/2443502 – Marcin Kłopotek Oct 29 '20 at 11:09

2 Answers2

0

To expand on merlin2011's comment, check your git credential helper:

git config credential.helper

On Windows, for instance, it should be the Windows Credential Manager, which would cache your credentials.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I know that what I am writing might not be helpful to the OP but I still write it in hope that it will help in clarifying someone's confusion or maybe mine in the future.

Cloning with HTTPS URLs

The https:// clone URLs are available on all repositories, regardless of the public or private repo. https:// clone URLs work even if you are behind a firewall or proxy.

When you git clone, git fetch, git pull, or git push to a private remote repository using HTTPS URLs on the command line and git fetch, git pull or git push to a public remote repository, Git will ask for your GitHub username and password. When Git prompts you for your password, enter your personal access token (PAT) instead. Password-based authentication for Git has been removed. see "Creating a personal access token"

You can save these username and password(PAT) in your repo/.git/config to make it not ask everytime. see this StackOverflow answer

Cloning with SSH URLs

To use these URLs, you must generate an SSH keypair on your computer and add the public key to your account on GitHub.com.

When you git clone, git fetch, git pull, or git push to a remote repository using SSH URLs, you'll be prompted for a password and must provide your SSH key passphrase. But if you set no passphrase in the first place then it won't ask you.

See this StackOverflow answer if your ssh-agent continues to annoy you by asking passphrases every time you do push pull.

Although most of the content is sourced from github-docs but it has a mistake you can see if you try to find change

HARSHAL RATHORE
  • 103
  • 1
  • 9
  • 2
    This is mostly plagiarized [from GitHub](https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories). Please make sure to put quoted material in a blockquote and provide a reference link. See [answer]. – ChrisGPT was on strike Nov 27 '21 at 13:47
  • yes most of the content is from github docs but there is a mistake in docs and my answer don't that is github-docs=>When you git clone, git fetch, git pull, or git push to a remote repository using HTTPS URLs on the command line, Git will ask for your GitHub username and password. see for difference – HARSHAL RATHORE Nov 27 '21 at 17:49
  • @Chris whereas my says that git clone of HTTPS URL does not require git prompting password and username. But you are right initially I did not add the source I now have. – HARSHAL RATHORE Nov 27 '21 at 17:57
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 27 '21 at 19:15
  • 1
    @HARSHALRATHORE, you _must_ quote anything taken from another source and provide a link back to it. Including it in your answer as if you wrote it is plagiarism, and that is not tolerated here. Please further [edit] your answer and explicitly quote what you borrowed by prefixing it with `>` or using the `"` button. – ChrisGPT was on strike Nov 27 '21 at 19:36