650

I am having a very strange problem with git and github. When I try and push, I am getting:

git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

I added the remote:

git remote add origin git@github.com:account-name/repo-name.git

Any ideas?

Justin
  • 42,716
  • 77
  • 201
  • 296
  • 7
    Yes that is how I got the `git remote add origin git@github.com:account-name/repo-name.git`. It exists in GitHub, and its a private repo. – Justin Apr 12 '12 at 01:51
  • Well I don't see anything you're specifically doing wrong. Have you got any other similar repositories that work? Have you contacted GitHub support? – Greg Hewgill Apr 12 '12 at 01:52
  • 1
    did you double check your user and repo names? – thescientist Apr 12 '12 at 01:54
  • 2
    did u change your github user name – Ankit May 05 '12 at 03:28
  • 1
    none of the 10 answers below have worked for you? – dhaval Jul 09 '13 at 03:48
  • 4
    Any chance this is related to the read/write permissions on the repo? I have a read only repo and I get this message when I try to push something – Michael Feb 20 '14 at 05:29
  • I was so convinced that I had read-write access to the project since I could check it out. Also the sibling project I could also read-write. But @Michael is right: My problem is ````write permission````! My setup is: - I have my own github account - I work on an another account's (lets call it companyX) project a w/ read-write - problem: I work on another companyX account's project where I only had read access. ...Did cost me a couple of hours... – Dirk Schumacher Nov 22 '17 at 09:36
  • 6
    I had the same problem. I solved it by updating the .git/config file. I put the username in the URL key of `[remote "origin"]` section. – Ahmed Jehanzaib Jul 10 '18 at 10:59
  • 1
    Just add your git usernane with your repo somthing like https://myusername@github.com/youruserusername/yourrepo.git edit file ./.git/config and put username in url like mentioned above now when you run run your git push it will ask you for password this happens because maybe from other repo you have globally saved username and password which cached and your current repo uses different git account – Vikas Kandari Dec 30 '19 at 12:29
  • For those who are not familiar with the command line, I suggest downloading and installing [GitHub Desktop](https://desktop.github.com/) which can help with that. Good luck! – Celso Jr May 11 '20 at 02:29
  • 1
    I tried everything for 5,6 hours. It was the problem with the write permission in my case. – Jamil Feb 02 '21 at 19:18

70 Answers70

756

Check to see if you have read-write access.

The Git error message is misleading. I had a similar issue. I had been added to an existing project. I cloned it and committed a local change. I went to push and got the ERROR: Repository not found. error message.

The person who added me to the project gave me read-only access to the repository. A change by them and I was able to push.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
JT.
  • 7,966
  • 1
  • 15
  • 10
  • 476
    Gotta love those useful Git error messages. Can't find the repository that I just cloned from, huh? Liar. – Grant Birchmeier Jul 13 '12 at 15:47
  • yep same problem here--no commit rights and you get this very obfuscated error message – rogerdpack Mar 14 '14 at 17:43
  • 26
    Thankyou! You can check this by viewing the project on the web and clicking on "New File" – Ronnie Feb 03 '16 at 14:32
  • For how to check which permissions you have to a repository, check [this stackoverflow answer](http://stackoverflow.com/a/21006487/854151) (to a different question). – Anders Rabo Thorbeck Dec 20 '16 at 14:43
  • 3
    So for me, my password had a ` (tick) in it and PhpStorm was removing the character before sending the git push: Lets say for this example my password is `_pa``ssword_` Phpstorm would output the following: `https://_username_:_password_@github.com/_username_/repo.git` instead of `https://_username_:_pa``ssword_@github.com/_username_/repo.git` Changed password to something not using the ` character. WORKS!!! – Ruben Arevalo Apr 19 '17 at 17:53
  • Had a similar problem. One of the repos i had the write access previously, but some one has changed the permission and took a while to figure out what happened. – aravindaM Jul 10 '17 at 02:44
  • This is it. I was using a personal access token to log in to GitHub. but I hadn't granted the right permissions while creating the token. The error message is quite misleading – tayo Jul 21 '19 at 06:26
  • Sometimes if you use many accounts on your system. there might be an issue of you forgetting to register your key with `ssh-agent`. run `ssh-add ~/.ssh/{Key name}` to register key with `ssh-agent`. – Jaimin Bhut Dec 05 '21 at 11:57
  • The solution does not work for me. I created and used a github token with EVERY possible permission. – Alex Feb 08 '22 at 08:26
  • If you have a saved personal access token being used to authenticate to the repo, and it is expired, it will show this error. Check ~/git-credentials and delete if necessary. – Bob Arezina Sep 19 '22 at 01:35
  • I had read-write access but wasn't using my ssh key. After I generated ssh keys with my email and added them to GitHub, I was able to push. To generate ssh keys - `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` – Loner Oct 20 '22 at 09:27
325

I had the same problem, with a private repo.

do the following:

remove the remote origin

git remote rm origin

re-add the origin but with your username and pwd with writing privileges on this pvt repo

git remote add origin  https://USERNAME:PASSWORD@github.com/username/reponame.git
Emi-C
  • 3,832
  • 1
  • 15
  • 15
  • 23
    What if the password has @? – AnupamChugh Sep 24 '18 at 06:44
  • 34
    @AnupamChugh you need to replace '@' with '%40' in your password. Basically you can check by running JS code `encodeURIComponent(password)` – elquimista Oct 17 '18 at 12:09
  • And I recommend using SSH instead of https, because especially for GitHub, using https will require additional step if you enabled 2FA. – elquimista Oct 17 '18 at 12:10
  • 4
    I recommend using a credential helper rather than storing your password in plain text: https://help.github.com/articles/caching-your-github-password-in-git/ – johnsyweb Dec 21 '18 at 09:05
  • I renamed the repo. `git remote rm origin` and adding repo usual way without password helped me. – user158 Jul 24 '19 at 14:35
  • 6
    Finally! The catch is for the PRIVATE REPO. This worked if you have a Private Repo and gettting this error by following Git hub instructions to push an existing repo from local in Xcode to remote in Github: `$ git push -u origin master remote: Repository not found. fatal: repository 'https://github.com/teksunios/Abc.git/' not found` – iHarshil Sep 17 '19 at 10:36
  • Remember to encode your password eg use PHP `echo urlencode('p+b/&6git67hub?p#t[$Trb%');` to encode your password – Bobby Axe Jan 14 '21 at 18:37
  • this can also happen if the repo was pulled using an oauth token for a different user account than you usually use, and now you're trying to push using your usual account. this fix (or a similar `git remote add origin git@github.com:/repo.git` using ssh) will work – Brian D Aug 18 '21 at 18:38
  • As of 13th August 2021, this approach is no longer supported by github,so this will not work. – Fewture Webdesign Aug 25 '21 at 16:41
  • 3
    @Fewture It still works, just replace password with Github Token, how to generate a personal access token: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token – Israel Obanijesu Aug 30 '21 at 03:41
  • Instead, you can just do it in one step `git remote set-url origin https://USERNAME:PASSWORD@github.com/username/reponame.git` – KJ Sudarshan Sep 24 '21 at 14:39
  • 1
    Indeed in 2021 it woks with token, need to make sure the token has repo rights in its scope – Infermath Oct 31 '21 at 10:05
  • 1
    Looks like adding origin like this will not work, please check this link for the updated solution : https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations – Shaggy Dec 04 '21 at 10:46
  • Does not work for me although I used a token with EVERY possible permission – Alex Feb 08 '22 at 08:26
  • 16
    Username and Password don't work anymore, instead, you have to use your [Personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token), like so `git remote set-url origin https://PERSONAL_ACCESS_TOKEN@github.com/username/reponame.git` – chavy May 17 '22 at 11:59
  • 1
    or do the browser login flow by running `gh auth login` – Andre Brdoch May 17 '22 at 13:14
  • 1
    Thank you. This solved my problem. Before that deleted all git credentials from credential manager and did not helped. – Davor Mar 02 '23 at 21:21
  • Update May 2023: changing the remote url to https://username@github.com/path-to/repo.git solved this issue – Alon Parag May 10 '23 at 06:37
168

I ran into the same issue and I solved it by including my username and password in the repo url:

git clone https://myusername:mypassword@github.com/path_to/myRepo.git
George Eracleous
  • 4,278
  • 6
  • 41
  • 50
  • 50
    This worked for me by added just my username: `https://myusername@github.com/path_to/myRepo.git` – redolent Jul 30 '14 at 19:19
  • 14
    this works but of course a lot of people would consider it a security problem; use with caution – Alexander Mills Jan 29 '17 at 05:58
  • This worked for me. I had used Git Bash previously for a different account and couldn't figure out how to change the account, so there ya go. Don't like it, but it works. – HartleySan Oct 04 '17 at 01:54
  • 2
    As a follow-up to my original comment, once you successfully push once, you can use the `git remote set-url origin url` command to change your origin URL to the same thing without the user name and password, and then it works fine. – HartleySan Oct 04 '17 at 01:56
  • I recommend using a credential helper rather than storing your password in plain text: https://help.github.com/articles/caching-your-github-password-in-git/ – johnsyweb Dec 21 '18 at 09:06
  • Why are you talking about cloning? – Yeats Jun 18 '19 at 15:19
  • Yes that problem often arrises when working with more than one Github account on the same maschine – Torsten Barthel Oct 01 '20 at 17:58
  • 3
    As of 13th August 2021, this approach is no longer supported by github,so this will not work. – Fewture Webdesign Aug 25 '21 at 16:40
  • this worked. Generate a 'Personal access token' and use it as password. – NiRUS Nov 23 '21 at 18:12
  • username:password does not work, however just use username@github.com and it will prompt you to authenticate. – user890332 Jul 21 '23 at 17:07
129

If you use Git on Windows, try to clear your credentials:

  1. Locate "credential manager" (should be in your Control Panel)
  2. Remove all credentials related to GitHub

enter image description here

SandroMarques
  • 6,070
  • 1
  • 41
  • 46
  • 9
    Nice - thanks for this successful hint! BTW, with following command you can navigate directly to the credential manager: "control.exe /name Microsoft.CredentialManager" – Chris Jan 23 '19 at 16:07
  • 6
    This worked, I had another account on github that caused the problem – Mokhtar Ashour Oct 15 '19 at 20:52
  • You saved my time. I had the same issue after using sourcetree. I added multiple git accounts, which ruined Git configuration. After removing credentials, it worked like a charm.Thanks – iconique Mar 10 '20 at 23:44
  • I had remove all credentials from the it and then try to push it again on the repo and I am getting the same error! "Repo not found" – Jayna Tanawala Sep 19 '22 at 12:16
88

I was getting the same error

ERROR: Repository not found.   
fatal: The remote end hung up unexpectedly

and I had created the repository on Github and cloned it locally.

I was able to solve by opening .git/config and removing the [remote "origin"] section.

[remote "origin"]   
   url = git@github.com:alexagui/my_project.git  
   fetch = +refs/heads/*:refs/remotes/origin/*

then I ran the following (again)

git remote add origin git@github.com:alexagui/my_project.git  
git push -u origin master

and this time I was able to push to the repository.

Alex Aguilar
  • 980
  • 5
  • 9
  • 3
    Could you please explain how did you open .git/config and remove the [remote "origin"] section? – Davi Moreira Aug 19 '13 at 15:46
  • I came here looking for answers to a similar problem. I had created a new repository from IntelliJ IDEA, but got the same error message when I tried to do my initial push. Alex Aguilar's answer inspired me to go in the .git/config file and edit the repository URL so that it used my username with a capital first letter, which it initially did not do. It fixed my problem. – Vallle Oct 24 '13 at 14:52
  • The `.git/` directory can be found on the project's root directory. – Gui Imamura Aug 05 '15 at 19:28
  • That also fixed the problem for me - I tried to switch user in the middle of a project and it opened a world of pain – gotofritz Jun 13 '18 at 08:26
  • why would that be necessary? I changed my username and now I'm facing all sorts of issues. – AjB Jan 04 '19 at 01:13
  • BTW, Thanks for saving the day – Manoj Kumar Mar 20 '20 at 19:52
  • 1
    @DaviMoreira you can open and edit your .git/config via `sudo nano .git/config` or via `vim .git/config` . Both open an inline editor, for the first one you need your sudo password. I recommend googling some short cuts on how to save and exit either one. – Suki Sep 19 '21 at 18:46
  • This worked for me, but I also had to delete the `[remote "upstream"]` section. I had the error because I changed remote from one repo to another one with a different name.... – Suki Sep 19 '21 at 18:47
  • For me I was adding remote by using https, and then solution is to remove it first, and then re-add remote origin but using git url – Windo Jul 10 '23 at 05:38
60

I got this error (but before was working). My problem was the missing ssh key binded with the Github account. You can check you current ssh keys with ssh-add -l.

If your key is missing, you can add it with

ssh-add ~/.ssh/your_key
Matteo Alessani
  • 10,264
  • 4
  • 40
  • 57
52

I faced this error when I was trying to push to a private repo that I had access to before. The problem was not whether the repo is private or public, the issue is that the Github API uses personal tokens instead of username and password for authentication and authorization now.

The following solved my problem:

  1. remove the remote origin: git remote remove origin

  2. Generate a personal token: you can find the instructions in Github Docs.

  3. Re-add the origin but with your username and the generated token:

git remote add origin https://USERNAME:GENERATED_TOKEN@github.com/username/reponame.git

N.B. If you encounter this issue a while after creating and using your token, make sure the token is not expired. If it is, regenerate it and make sure to repeat step 3 (mentioned above) for the repos that used the old token. Also, if you changed your token, redo step 3 for the repos that used the old token.

moebius
  • 2,061
  • 11
  • 20
Dr.Simplisist
  • 675
  • 1
  • 8
  • 16
33

I'm using Mac and I struggled to find the solution. My remote address was right and as said, it was a credentials problem. Apparently, in the past I used another Git Account on my computer and the mac's Keychain remembered the credentials of the previous account, so I really wasn't authorised to push.

How to fix? Open Keychain Access on your mac, choose "All Items" category and search for git. Delete all results found.

Now go to the terminal and try to push again. The terminal will ask for username and password. Enter the new relevant credentials and that's it!

Hope it'll help someone. I struggled it for few hours.

Gal Shahar
  • 2,695
  • 1
  • 21
  • 29
27

I had a similar problem. The incorrect credentials were cached in OS X's key-chain.

Check out: https://help.github.com/articles/updating-credentials-from-the-osx-keychain

Nikola
  • 817
  • 13
  • 19
  • 3
    Same issue. I get `remote: Repository not found.` when accessing to private repo. It was because still connected to repo with old credentials (even with new ones in local git config). To fix 1) remove key from keychain. 2) do the command in the terminal again. 3) Should ask for username and password. – Nike Kov Feb 15 '17 at 10:29
  • 2
    This fixed the issue for me. Nuked the credentials in keychain, got a new personal access token via Github GUI and am off and running, thanks. – Anthony Jul 26 '17 at 17:48
  • @Antoine's answer is what happened to me. Unfortunately, I found this after I fixed the problem. In my case, I just turned on 2FA (Two Factor Authentication) (TFA). This broke my password. So, I cleared credentials (like people on this page said) but recloning a repo still failed with my password (I'm guessing due to 2FA). So, I created Personal Access Token (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) to use in place of the password. I gave it repo access only since it's on the command line. – cwingrav Mar 20 '18 at 12:10
25
git remote rm origin
git remote add origin <remote url>
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
21

remote: Repository not found. can be a frustratingly misleading error message from when trying to push to an HTTPS remote where you don't have write permissions.

Check your write permissions on the repository!

Trying an SSH remote to the same repository shows a different response:

% git remote add ssh git@github.com:our-organisation/some-repository.git

% git fetch ssh
From github.com:our-organisation/some-repository
* [new branch]        MO_Adding_ECS_configs             -> ssh/MO_Adding_ECS_configs
* [new branch]        update_gems                       -> ssh/update_gems

% git push ssh     
ERROR: Repository not found.
fatal: Could not read from remote repository.

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

"The correct access rights?"

Well why didn't you say so?

It's worth noting at this point that while the SSH failure mode in this scenario is slightly better, I use HTTPS remotes over SSH because GitHub recommend HTTPS over SSH.

I understand that GitHub uses "Not Found" where it means "Forbidden" in some circumstances to prevent inadvertently reveling the existence of a private repository.

Requests that require authentication will return 404 Not Found, instead of 403 Forbidden, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.

--GitHub

This is a fairly common practice around the web, indeed it is defined:

The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

--6.5.4. 404 Not Found, RFC 7231 HTTP/1.1 Semantics and Content (emphasis mine)

What makes no sense to me is when I am authenticated with GitHub using a credential helper and I have access to that repository (having successfully cloned and fetched it) that GitHub would choose to hide its existence from me because of missing write permissions.

Checking https://github.com/our-organisation/some-repository/ using a web browser confirmed that I didn't have write permissions to the repository. Our team's GitHub administrators were able to grant my team write access in a short time and I was able to push the branch up.

Community
  • 1
  • 1
johnsyweb
  • 136,902
  • 23
  • 188
  • 247
21

Github removed use of username and passwordon August 13, 2021. Now uses personal tokens instead

To overcome that generate a personal token using create personal token. And use the following snippets to achieve push and clone functionalities

To Push

git remote remove origin
git remote add origin https://[USER]:[TOKEN]@github.com/[USER]/[REPO]
git push

To Clone

git clone https://[USER]:[TOKEN]@github.com/[USER]/[REPO]
krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88
17

If your repo was working normally before, and suddenly this error pops up, most likely the reason would be that your git is authenticated as some other user, that does not have access to the repository. So, in order to push, all you need to do is, specify your correct username and password in your git command. So, a push command for a github repo would look like:

git push https://youruser:password@github.com/user/reponame.git

username and password needs to be url-escaped, so an @ should be replaced by %40, and so on.

MrClan
  • 6,402
  • 8
  • 28
  • 43
14

That's what worked for me:

1. The Remotes

$ git remote rm origin
$ git remote add origin git@github.com:<USER>/<REPO>.git

If your SSH key is already in use on another github rep, you can generate a new one.

2. Generating a new SSH key

$ ssh-keygen -t rsa -b 4096 -C "web@github.com"

3. Addition of the key at the SSH agent level

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github

4. Add the new key to the Github repo.

120DEV
  • 805
  • 10
  • 8
11

One problem, that may be obvious to some that I don't see mentioned here, could be that you have access with ssh keys, but you are trying to connect your local repo to a remote via https.

If this is the case then the following commands should fix the issue for you:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin git@github.com:private-repo.git
$ git remote -v
origin  git@github.com:private-repo.git (fetch)
origin  git@github.com:private-repo.git (push)

Note that the above works assuming that:

  1. your current remote is named origin and that you do already have a generated ssh key connected with your github account

  2. you already have an ssh key associated with your github account (and connected locally)

  3. you have the correct permissions (read/write) set on github for this repo's settings.

John Donner
  • 524
  • 6
  • 14
  • This worked for me. But what was the breaking change? It was working fine just the other week and this was a repo I've had around for years. – Dylan Nissley Apr 12 '18 at 16:38
  • @DylanNissley perhaps the security settings of the repo changed? I'm not sure, to be honest. :/ – John Donner Jun 29 '18 at 16:33
10

Had similar issue. The root of the problem was that I followed some online tutorial about adding a new repository to Github.

Just go to Github, create a new repo, it will ask you to add a README, don't add it. Create it, and you'll get instructions on how to push.

It's similar to the next two lines:

git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master
valk
  • 9,363
  • 12
  • 59
  • 79
10

If you belong to a group in Github check that you have Write Access.

Eduardo Chongkan
  • 752
  • 7
  • 12
  • 1
    How exactly does one do that? It would be more complete if you could add such info. – Renato Back Jan 20 '17 at 00:17
  • 3
    just got to your git repository and click on any file and try to edit it.If you dont have write access then you will shown some error like "you are trying to edit a file ...." – mohor chatt Dec 21 '17 at 03:23
  • 5
    A quick way to check is to click `Create new file`. If you get a message saying "You’re creating a file in a project you don’t have write access to", then you don't have write access. – wisbucky Jan 12 '18 at 00:07
9

I ran into the same issue on a MAC trying to pull from a private repo i was previously connected to.

I solved it by including my username in the repo url:

git remote set-url origin https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git

Then i was able to pull from the repo.

For a new repo you want to clone:

git clone https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git    

It will prompt you to enter your password to that account, you're good to go afterwards.

davyCode
  • 399
  • 4
  • 4
  • I am on a Mac, I'm using a private repo that I've been able to pull from. Unfortunately, this didn't solve the problem for me. – Nick K9 Aug 07 '20 at 16:26
  • Thanks for checking in. The problem was that I had read but not write access to the repo. – Nick K9 Aug 23 '20 at 19:33
8

This Solved my problem.

   git pull https://myusername:mypassword@github.com/path_to/myRepo.git
Eyad Farra
  • 4,403
  • 1
  • 24
  • 26
8

To solve this problem (on Linux), I merely had to run this:

git config --global --unset credential.helper
ktolbol
  • 91
  • 1
  • 1
7

The Problem: Github is not familiar with your repository from some reason.

The Error: prompted in git cli like the following:

remote: Repository not found. fatal: repository ‘https://github.com/MyOrganization/projectName.git/’ not found

The Solution : 2 Options

  1. Github might not familiar with your credentials: - The first Option is to clone the project with the right credentials user:password in case you forgot this Or generate ssh token and adjust this key in your Github. aka git push https://<userName>:<password>@github.com/Company/repositoryName.git

  2. Repo Permissions Issue with some users - In my Use case, I solved this issue when I realized I don't have the right collaborator permissions on Github in my private repo. Users could clone the project but not perform any actions on origin. In order to solve this:

Go to Repository on Github -> Settings -> Collaborators & Teams -> Add Member/Maintainer your users -> Now they got the permission to commit and push

avivamg
  • 12,197
  • 3
  • 67
  • 61
6

You need to check your SSH access as the following:

ssh -T git@github.com

this issue was because i don't add the person response on SSH in repository, read more about SSH link-1, link-2.

Mohamed Yakout
  • 2,868
  • 1
  • 25
  • 45
  • This showed up an issue with multiple keys and a config file that wasn't working. Thanks for the tip. – dibs Apr 11 '16 at 23:57
6

Here is how to solve my issue

#check current github account
ssh -T git@github.com

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin git@github.com:YOUR-USER/YOUR-REPO.GIT
git push -u origin master
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
6

If you clone from github using https but you are using ssh to push, you can also get this error.

To correct this, open .git/config and replace:

url = https://github.com/company/project.git

With

url = git@github.com:company/project.git

And you should be able to push with no warning...

Neil
  • 7,861
  • 4
  • 53
  • 74
6

I solved that issue by re-authentifacating with Github.

If you have Github CLI, you can type gh auth login

Leo Seyers
  • 197
  • 2
  • 7
  • I had issues writing to an organization repo. By default you only get read access to org repos. The gh cli makes it easy to get write access too by running `gh auth login --scopes write:org` – Joakim Jan 17 '23 at 12:50
5

Have experienced the same problem. Everything was working fine for years and then suddenly this error.

The problem turns out was that I added a deploy key for another repo to my SSH agent before my user's github SSH key (which I always used to access the repo in question). SSH agent tried the deploy key for another repo first, and GitHub for some totally unexplainable reason was saying

ERROR: Repository not found.

Once I've removed the deploy key from SSH agent, everything was back to normal.

snovity
  • 488
  • 4
  • 11
  • This is the only thing that worked for me, specifically by running `ssh-add -D`. This is on macOS. – dipea May 04 '21 at 20:22
5

The following solved the problem for me.

First I used this command to figure what was the github account used:

ssh -T git@github.com

This gave me an answer like this:

Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.

Then I understood that the Github user described in the answer (github_account_name) wasn't authorized on the Github repository I was trying to pull.

Stéphane
  • 1,476
  • 3
  • 12
  • 12
  • What to do if i get this error: `The authenticity of host 'github.com (192.30.253.112)' can't be established. RSA key fingerprint is SHA256.... Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts. Permission denied (publickey).` – Nike Kov Feb 15 '17 at 10:19
5

I had the same problem. Try the following:

1. Modifying the Keychain Access in Mac for git credentials solved the problem for me.
2. Resetting origin url

git remote rm origin
git remote add origin git@github.com:account-name/repo-name.git
5

I was having the same issue with one of my Github Repository.

Way around:

Used SSH instead of HTTPS and then push/pull started working fine.

Safeer
  • 1,407
  • 1
  • 25
  • 29
5

I can explain how i get into the similar situation, and then will list steps that i have taken to solve this issue.

I am using
Windows 10,
git: git version 2.27.0.windows.1.

I had already setup the git and was doing git push activities. Windows Credential Manager stores the username and password so you don't have to enter username and password every git remote activities.

The encounter this problem, when i added another github account and used --local git settings. After few days, I encounter the Repository not found problem, upon investigation i found:

  1. Even if you remove the git details from Windows Credential Manager, it will save again the username, email details you enter.

So, if you are using two git accounts, you need to use (git bash as an administrator)

git config --edit --system 

and remove the

helper = manager 

line so that it is no longer registered as a credential helper. But it will ask you login details every time you do any remote activities.

How do I disable Git Credential Manager for Windows?.

To check remote origin, user details

git config --list --show-origin
gs1208
  • 73
  • 5
  • 9
5

Just use the SSH remote url instead of the HTTPS

Misterwyz
  • 101
  • 1
  • 2
  • 6
4

Changing the content of the .git/config file helps as Alex said above. I experienced the same problem and I think it was because I changed my Github username. The local files could not be updated with the changes. So perhaps anytime you change your username you might consider running

git remote add origin your_ssh_link_from_github

I hope this helps ;)

Yaw Boakye
  • 10,352
  • 1
  • 17
  • 25
4

If anybody faced the issue at github.com check if you have accepted an invitation after repo owner allowed commits to you. Until you accept invitation repo will be invisible for you. So you'll get ERROR: Repository not found.

zelibobla
  • 1,498
  • 1
  • 16
  • 23
4

Normally it happens because the project is private and you have not rights to write it. I had the same "problem" a few times, and it was for that reason. If the project it is yours, just create a private and a public key following this link: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and add them to the "SSH and Key" section on gitHub, then you will be able to push to the repo. In the other hand if the project it is not your, ask the owner to give you the rights for it.

R0bertinski
  • 517
  • 6
  • 12
4

My solution was this:

git remote rm origin
git remote add origin https://USERNAME@github.com/username/reponame.git

Similar to Emi-C's answer but without passwords.

Coconut
  • 2,024
  • 18
  • 25
4

If you are sure you already have SSH access to this repository.

Do

git clone https://myusername@github.com/path_to/myRepo.git
king
  • 273
  • 5
  • 8
4

In my case it was because of that I added the same SSH key in another GitHub account also. Steps to check and fix

  1. Check it: ssh -T git@github.com. If it shows the correct username then the issue is different. If it is another account then do step 2.
  2. Simply go to another account and delete ssh keys from there.
  3. Use different keys for different accounts. Github really mix up them.
Nasir Aliyev
  • 116
  • 7
3

Before following this, make sure you've write permission to the repo. If you're still getting the error, do the following :

  1. Generate a personal access token from your account from Settings > Developer Settings > Personal Access tokens. Keep the token safe somewhere.

  2. Go to your repository and run the following:

    git remote rm origin

  3. Then add a new origin along with your username:

    git remote add origin https://USERNAME@github.com/REPOSITORY_LINK.git

  4. Now when you push the code, a prompt will show up asking for your password or personal access token. Paste the token that we generated in the first step in the field, and we're done.

3
eval "$(ssh-agent -s)"

It was my own repo - there should be enough access. For other repos I was able to pull & push with no problem. It was solved by starting ssh-agent over again. I use macos.

kangkyu
  • 5,252
  • 3
  • 34
  • 36
2

I had the same problem. My issue was misunderstanding that I had to first create the empty repo on github before pushing to it. Doh! Including this here for anyone else who doesn't realize.

Nate Barr
  • 4,640
  • 2
  • 25
  • 21
2

go to your project folder then search for the .git folder, then open the config file with notepad and check if there is your link to the github repo under: [remote "origin"], if it is different then the repo in your github then just edit it, or open a new repo with the name in the in config file

TooCooL
  • 20,356
  • 6
  • 30
  • 49
2

If you use private repository check you connection user, it must have permission for use repository.

Max
  • 4,292
  • 1
  • 20
  • 14
2

I had this issue and realized I was using a different account from the one whose repo it was. Logging in as the original user resolved the issue.

Keyslinger
  • 4,903
  • 7
  • 42
  • 50
  • In my case I had set up 2 accounts and added entries in .ssh/config for alias work and personal and forgotten about it .So; changing the origin part in .git/config of the project directory so that I had work instead of 'github.com' solved the issue.Problem was that while cloning I had used git@github.com:blahblah and not git@work:blahblah. – sourabh Apr 02 '17 at 15:56
1

My solution may be useful to some of you.

I got the same error after updating my macbook's OS to Yosemite. My problem got fixed by recreating my ssh key. You can do this by following step 2 of this page: https://help.github.com/articles/generating-ssh-keys/

Luc
  • 1,765
  • 5
  • 24
  • 44
1

So for me, my password had a ` (tick) in it and PhpStorm was removing the character before sending the git push:

Lets say for this example my password is _pa``ssword_

Phpstorm would output the following:

https://_username_:_password_@github.com/_username_/repo.git

instead of

https://_username_:_pa``ssword_@github.com/_username_/repo.git

Changed password to something not using the ` character. WORKS!!!

Ruben Arevalo
  • 367
  • 2
  • 4
  • 8
1

I needed to kill credential-helper processes (were multiple) and it solved the issue after providing credentials once again.

killall git-credential-cache--daemon

optivian
  • 103
  • 8
1

I am having the same problem and tried many ways but at last, I have got to know that I don't have sufficient permissions to push or pull on this repo and one more way to check if you are having the permissions or not is you were not able to see settings option in that repo and if you were having permissions then you will be able to see settings option

Thanks! this is what I observed

1

enter image description here

Step 1:

Copy the link from the HTTPS

Step 2:

in the local repository do

git remote rm origin

Step 3:

replace github.com with username.password@github.com in the copied url

Step 4:

git remote add origin url
Viraj Singh
  • 1,951
  • 1
  • 17
  • 27
1

I (and many others) have had this problem since may 2021. Something seems to have changed in actions/checkout@v2 (GitHub issue: https://github.com/actions/checkout/issues/254)

I resolved it by changing the way the runner authenticates to the repo by using this step.

- name: Bump version
    env:
      NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
    run: |
      npm run release
      git remote rm origin
      git remote add origin https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/project/repo.git
      git remote -v # for debug only 
      git show-ref # for debug only 
      git push --follow-tags origin HEAD:master

All you need to do is to change the repo url. Username and password will be replaced at runtime by the GitHub runner. This works for both actions/checkout@v1 and actions/checkout@v2 (haven't tested others).

Also many snippets you find online already come with a permission restriction that will prevent you from pushing back to the repo

permissions:
   packages: write
   contents: read

Make sure you remove this or grant your action contents:write permission if you need to push a tag or commit release notes and package bumps.

Claudio
  • 92
  • 2
  • 11
1

My problem was that I created a personal developer token without permissions

Rafa
  • 61
  • 7
1

In my case this was caused by git using the wrong ssh private key. I was given access to the repository under a specific github user account I am using for school. My default ssh private key was unfortunately linked to a different github account.

If you do ssh -T git@github.com ssh will automatically use your id_rsa private key to connect to github.

Using ssh -i ~/.ssh/<some-key> -T git@github.com should result in github greeting you with the account you linked to that key.

So what happened in my case was that git was using my default ssh private key which was linked to the wrong github account which didn't have access to the private repository I was trying to access.

To solve this I told git to use the correct ssh command in the local git config for my repo using the command: git config core.sshCommand "ssh -i ~/.ssh/<correct private key here>"

Viewing the git configuration git config -l should show that the line was properly added.

1

This answer is specific to IntelliJ products such as IDEA / WebStorm / PHPStorm when using organizations.

I had this problem with WebStorm when trying to push to a repository that was part of an organization, meanwhile pushing to a repository within my normal private account worked.

Also, pushing to my organizational repository with IntelliJ IDEA worked

So I thought this could only be something related to a setting that differs between both IDEs, and I found out that I had the checkbox "Use credential helper" enabled in WebStorm, and disabled in IDEA.

enter image description here

Disabling the credential helper made it working!!

Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
1

Had this same issue when working on a MacBook Pro.

When I try to clone a repository, I get the error below:

git clone https://github.com/mytech/mytech_frontend.git

Cloning into 'mytech_frontend'...
remote: Repository not found.
fatal: repository 'https://github.com/mytech/mytech_frontend.git/' not found

Here's how I solved it:

First, be sure you have access to the repository either as:

  • a member of the organization in which the repository resides OR
  • a collaborator of the repository

Next, clone the repository using:

git clone https://github.com/path_to/myRepo.git

if you have an existing GitHub account on the computer/terminal, when you try to clone from a repository with another GitHub account you will encounter the same error, so you need to modify your git clone command to:

git clone https://myusername:'personal-access-token'@github.com/path_to/myRepo.git

Example:

git clone https://promisepreston:'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'@github.com/promisepreston/my-writings.git
Promise Preston
  • 24,334
  • 12
  • 145
  • 143
1

If you had everything automated by vscode before and now it's no longer working, Try signing out of your connected github account on vscode and signing back in to the right github account that has access to that repository.

Here is where you sign out and sign back in.

enter image description here

Cels
  • 1,212
  • 18
  • 25
0

If you include your username and the repo name we can reasonably help you, at the moment we have no reason to think the repo does actually exist.

Additionally, if the repo is private and you don't have access to it, github returns "Does not exist" to avoid disclosing the existance of private repos.

EDIT: If you're not able to clone it because it's saying it doesn't exist and it's private, it's because you're not sending authentication. Ensure that your public key is added to your keyring, or use HTTP basic auth for the time being.

richo
  • 8,717
  • 3
  • 29
  • 47
0

I faced same error after updating my ubuntu to next version

I just deleted my sshkey on github account and then re added an sshkey to that account.

Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53
0

I was getting the same error coz I change my github user name, then I do this:

git remote -v

then:

git remote set-url newname newurl 
git push -u origin master

this time I was able to push to the repository. I hope this helps.

0

first Create a new repository on the command line, name like Ademo.git

Create a new repository on the command line

touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/your_name/Ademo.git git push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/your_name/Ademo.git git push -u origin master

0

Create a Fork

If don't have write access to that repository, you don't need it. Create a fork by following these instructions -- it's your own clone of the repository which you can modify freely.

After creating the fork, you can then clone that repo to your computer.

git clone git@github.com:<your-git-handle>/<repository>.git
// It will be cloned to your machine where you run the command 
// under a <repository> folder that it will create.

Checkout a new branch and make changes.

git checkout -b my-new-feature

To submit your changes to the original repository, you'll need to make sure that they're pushed

/* make changes */
git commit -am "New Feature: Made a new feature!"
git push origin my-new-feature

To get these changes into the original repository that you forked from, you can submit a Pull Requests by following these instructions. A Pull Request basically, you request that the user with write access to a repository pull down the changes you've made. Think of it like "I request that you pull my changes into your repo."


Note: Your fork will not stay up-to-date with all of the changes going on in the original repository, though. You'll have to pull down those changes periodically -- but this is easy.

After creating the fork, you can link to repo that you've forked from so that you can pull in it's changes and keep stay current.

git remote add upstream git@github.com:<git-user-handle>/<repository>.git

Once you've done that, keeping in sync with the changes made on the original repo is quite easy.

git checkout master         // checkout your local master
git pull upstream master    // fetch changes from the master branch of the repo you forked from.. which is linked to your fork under the alias "upstream" (common naming convention)
git push origin master      // push the pulled changes onto your local master
git checkout -b new-branch  // create a new branch and start making changes
Cory Danielson
  • 14,314
  • 3
  • 44
  • 51
0

This can also happen because GitHub itself is down. Make sure to check status.github.com to see if the problem might lie on their side.

On October 22nd 2018 you couldn't push to GitHub for several hours.

Florian Bienefelt
  • 1,448
  • 5
  • 15
  • 28
0

I have the same problem.

I solved prefixing my gitlab username to the gitlab.com url, so like this: before: https://gitlab.com/my_gitlab_user/myrepo.git and after: https://my_gitlab_user@gitlab.com/my_gitlab_user/myrepo.git In this case will ask for the credentials again and it's done!

AlexPad
  • 10,364
  • 3
  • 38
  • 48
0

My code snippet:

environment {
    ...
    ...
    git_repo = 'my-repo'
}

stage ('Update Helm Chart') {
    steps {
        echo 'Updating values.xml file with latest Docker image tag'

        withCredentials([usernamePassword(credentialsId: '6bgg7dd45-c65f13-4275-a96ddehdv67gdr', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
            sh '''
                git checkout ${git_branch}
                ...
                ...
                git remote set-url origin "http://${GIT_USER}:${GIT_PASS}@git.example.com/scm/${git_repo}.git"
                git push origin ${git_branch}
            '''
        }
    }
}

My Git user name was deploy.user@example.com so i had to first URL encode @ to %40. After URL encoding, my user name became deploy.user%40example.com.

However, i was still getting the following error:

fatal: repository 'http://****:****@git.example.com/scm/my-repo.git/' not found

After some trial and error, i found that if i don't use variable for user name and instead hard-code it, it works.

git remote set-url origin "http://deploy.user%40example.com:${GIT_PASS}@git.example.com/scm/${git_repo}.git"
Technext
  • 7,887
  • 9
  • 48
  • 76
0

I had the same problem using Android Studio, I was unable to push commits because of the auth error.

My working temporary solution was to use the GitHub desktop app to push my commits and it works fine.

Daniel
  • 2,415
  • 3
  • 24
  • 34
  • The terminal should behave more or less the same apart from visuals. So I doubt that makes any difference. – Cobolt Nov 02 '20 at 08:47
0

I tried all options, but nothing seemed to work. Further research revealed the following:

  1. Here is a comprehensive approach to solving the problem.
  2. When you get to 5. Fix 4, note that VS code will ask for authentication.

If you enter your password and still get an authentication error, do the following.

  1. Head over to your GitHub menu do Settings -> Developer Settings -> Personal access tokens -> Generate new token. And ensure the boxes are checked according to the picture below. Generate an access token and save it somewhere accessible. enter image description here
  2. Use the generated token instead of the password.
  3. Then continue to step 6. Fix 5

These steps should fix the problem afterwards.

odunayo12
  • 425
  • 5
  • 10
0

If you have 2 TWO(or more) GitHub accounts:

you will run into issue:

"key already in use" for the same computer

Solution:

  1. create a new key per each organization/account/email

    $ sudo ssh-keygen -t ecdsa -b 521 -C "other@email.com"

  2. add identity

    $ ssh-add ~/.ssh/"whatever key you created"

make sure to add all the "identities" or ssh keys which tells git which keys to try to use when authenticating with GitHub under all organizations.

moyoteg
  • 351
  • 3
  • 11
0

This SOLVED the problem:

  1. Check your link has correct spelling, you can copy on Github enter image description here

  2. If you're correct all the spelling, maybe your Credential Remote is the issue. Go to Control panel > User Accounts > Credential Manager > Windows Credentials. Find git:https://github.com and click Remove. enter image description here

Make sure you come to git:https://github.com not the other *..github.com enter image description here

Then, now you can do git clone or push or any with your repo. It worked for me!

  • Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? **If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient.** Can you kindly [edit] your answer to offer an explanation? – Jeremy Caney Jun 27 '23 at 00:29
-1

Also be sure to check whether you have desktop client installed. I double checked everything, my permission, SSH, but turns out my repo listed in the client was overriding the one I was inputting via terminal.

-1

you have to generate ssh key and add it in your github account in settings go to your project where you clone inside that run these command.-

1-ssh-keygen -t rsa -b 4096 -C "rajankumar148@gmail.com"

after the command you will get some options path and name can be leave empty and you can put password.

2-eval $(ssh-agent -s) .

3-ssh-add ~/.ssh/id_rsa

after this command you have to put same password that you created in 1st command

and after that you can check your default home directory or whatever directory it is showing on the terminal .pub file open and copy the key and past in github settings new ssh

Rajan rek
  • 322
  • 2
  • 8
-1

Using Ubuntu, I always have to add remote using SSH instead of HTTPS

git remote add origin git@github.com:username/project.git

instead of

git remote add origin https://github.com/username/project.git
Tomas Lukac
  • 1,923
  • 2
  • 19
  • 37
-1

For me, none of these replies were useful. I had just forgotten to create the repo on the remote (on github.com). So I created my repo online, using the same name, and then re-done

So, here is the whole story:

git init ...
git add ...
git commit ...
git remote add origin git@github.com:<myName>/<myRepo>.git
git push -u origin main

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

--> Here you need to add your repo on github.com with the same "myRepo" name

git push -u origin main