412

I have SourceTree with local working copy. And all operations work good, I can simple fetch, push, pull and etc via SourceTree. I just needed to make force push which does not exist in SourceTree.

I opened terminal made git push -f

remote: Repository not found.
fatal: repository 'https://github.com/MyRepo/project.git/' not found

I am not sure what can be an issue.

12
  • Are you sure this fails only with git push -f, but works with a regular push, pull and fetch?
    – everton
    Jun 14, 2016 at 14:00
  • Possible duplicate of Git Push ERROR: Repository not found Mar 1, 2017 at 3:58
  • 32
    For anyone else accessing using a personal access token, check in Settings -> Developer settings -> Personal access tokens and confirm write.packages is checked. This was my problem. Aug 30, 2021 at 21:55
  • 1
    kevin_theinfinityfpnd 's answer worked for me. Thanks.
    – ashishn
    Oct 17, 2021 at 15:39
  • 1
    My solution was to create the repo directly on github.com via the web page. Everything worked smoothly after that. I had been assuming that the repo would be created by the various commands discussed here. But no. You have to create the repo via the web page. Then try everything else you usually do. Dec 5, 2021 at 3:04

59 Answers 59

425

Remove all the github.com credential details from the system.

For mac

Delete the github.com password from the Keychain Access.

For windows

Delete the credentials from Credential Manager.

13
  • 19
    This is correct; at least for Mac. I removed everything that said "github" from Keychain Access (an application) and then it prompted me for my credentials on the command line when I tried to push.
    – Ryan
    Jan 22, 2019 at 1:44
  • 6
    "ALL" means all. Even if it says "web"
    – Max
    May 18, 2019 at 21:07
  • 7
    uhhh, beware this maneuver. I now cannot authenticate at all from the command line, even to repos that were working perfectly before
    – Ben
    Sep 22, 2020 at 15:41
  • 3
    Can you share me For ubuntu?
    – Kannan T
    Nov 6, 2020 at 12:22
  • 2
    what about linux ?
    – Digao
    Mar 26, 2021 at 18:55
265

Please find below the working solution for Windows:

  1. Open Control Panel from the Start menu.
  2. Select User Accounts.
  3. Select the "Credential Manager".
  4. Click on "Manage Windows Credentials".
  5. Delete any credentials related to Git or GitHub.
  6. Once you deleted all then try to clone again.

enter image description here

4
  • Great answer! I'll just add that in most cases deleting only the "problemtic" line should suffice. No need to delete them all.
    – Shaya
    Oct 7, 2020 at 13:06
  • 2
    In my case, I just edited the credentials for Git. Set Github email as username and password. And it worked. Dec 21, 2020 at 22:16
  • 1
    You can also edit the credentials in the keychain to the current Github account. It also works
    – blakroku
    Apr 28, 2021 at 19:29
  • I have nothing related to git there. Oct 15, 2021 at 15:22
127

I was also facing the same issue

remote: Repository not found
fatal: repository 'https://github.com/MyRepo/project.git/' not found

I uninstalled the git credentials manager and reinstalled it and then I could easily pull and push to the repository. Here are the commands

$ git credential-manager uninstall

$ git credential-manager install
9
  • 107
    git: 'credential-manager' is not a git command. See 'git --help'.
    – filiphl
    Nov 20, 2018 at 7:45
  • 2
    @filiphl Please see the Zeeshan Ansari's answer.
    – jiexishede
    Dec 5, 2018 at 2:48
  • 1
    so much search online. and this is the one that work for me
    – zeroflaw
    Jul 15, 2020 at 6:24
  • 21
    removal failed. U_U Nov 13, 2020 at 8:54
  • 4
    This might be a "windows only" thing despite the $? The fix worked perfectly for me. I also checked git --help and indeed, credential-manager isn't listed, but that's not the full list. git help -a does list 'credential' as a command. Anyway, this fix worked great.
    – J. Gwinner
    Mar 16, 2021 at 17:13
107

This message can occur when a repository IS found, but we don't have commit access. Not well-worded!

I received the repo-not-found message after cloning a gitHub repository created for me by my boss. I could clone and commit locally, but could not push commits upstream. The repository owner had not given me write access. Solved by a plea for write access to the repo owner.

5
  • 6
    In few casses, GitHub returns repo not found message which you don't have rights instead of permissions not granted. Oct 24, 2018 at 17:10
  • 4
    This was the case for me. Hope they can have a better error message than this.
    – madu
    Jan 7, 2021 at 2:47
  • 4
    This may actually be intentional since GitHub (as other sites do, too) also returns a 404 when trying to access a repository with insufficient permissions. For many sites, this is an additional security (or rather privacy) measure to prevent from crawlers or brute-force-sort-of-attacks. Mar 12, 2021 at 11:19
  • this should be answer number 1, easy fix and no messing with any local git settings
    – Andrei
    Jun 17, 2021 at 13:53
  • 2
    For anyone else accessing using a personal access token, check in Settings -> Developer settings -> Personal access tokens and confirm write.packages is checked. This was my problem. Aug 30, 2021 at 21:55
77

Because you probably did not identify the remote git repository to your terminal first.

git remote set-url origin https://github.com/MyRepo/project.git

OR if you are using SSH;

git remote set-url origin git@github.com:MyRepo/project.git

and then,

git add .
git commit -m "initial commit"
git push origin master
4
  • 17
    If you are using SSH, you will need to set-url like this: git@github.com:MyRepo/project.git
    – Fergus
    Apr 28, 2018 at 16:57
  • This one actually worked. The credential manager "answers" had no effect for me. Thank you. Mar 31, 2021 at 18:47
  • 1
    @Fergus had it figured out all along. I was reluctant to mess with my credentials manager and decided to try out as many other reasonable suggestions before I began messing with the credentials manager on windows. Using SSH instead of HTTPS fixed my issue. Thanks Fergus
    – wandesky
    Jun 29, 2022 at 5:51
  • This one works for me as easy as simple, thank you for this simple answer
    – DL Studio
    Apr 13 at 22:38
64

Add "Personal Access Token"

Since since 2021 Github supports PAT rather than name/password (read here how to create and use one) so we just add it into the remote origin.

On Windows

  1. Visit .git folder and open config file for editing. Eg. vim config.
  2. Change your URL from
    https://github.com/<username>/<repo_name>.git
    to
    https://[personal-access-token]@github.com/<username>/<repo_name>.git
    Where [personal-access-token] is the PAT hash you've created at github.
  3. Save the config file and now the push should work.

Shortcut:

git remote remove origin
git remote add origin https://[personal-access-token]@github.com/username/repo_name.git

Update

When generating a token, choose No expiration if you want it to work for long time. enter image description here

6
  • That did work once, but now not anymore. Even with a token with all possible rights, I cannot push to my own github
    – Alex
    Feb 8, 2022 at 8:43
  • @Alex, have you checked the token life-time ? It might be only a week or 30 days... Take a look at my Update. Feb 9, 2022 at 13:21
  • Of course, I even created a new token with all rights and used that like 1 minute later.
    – Alex
    Feb 9, 2022 at 14:57
  • @Alex, might it be the problem with smth. else besides the PAT ? Feb 10, 2022 at 15:35
  • For me it worked: git remote set-url origin https://$GITHUB_ACCESS_TOKEN@github.com/<user>/<repo>.git Where the env variable GITHUB_ACCESS_TOKEN is set to the github token
    – villamejia
    Oct 27, 2022 at 21:04
47

This issue here is you local git is not able to push the changes to the remote Check your remote is set correctly by

git remote -v

if it is not set properly try setting your remote as

git remote set-url origin https://username@github.com/MyRepo/project.git

Then try pushing using

git push -u origin master

Also there is a possibility of your local git has different credentials, please check that also.

6
  • 11
    I've been struggling with this for a while. the trick for me was adding my username to the url. then I was prompted for password and then it works. May 3, 2019 at 19:17
  • 1
    This simple fix solved it for me as well, without going through the hassle of removing existing credentials etc. On my initial push to the repo, I was asked for the password and added my repository's specific token. Everything has been working well ever since Apr 6, 2021 at 14:22
  • Same. Add username to the url to fix it in Sourcetree.
    – KulaGGin
    Apr 16, 2021 at 22:30
  • For me, I was using Azure DevOps and for whatever reason, the fetch and push URLs were different in the "Manage Remotes" window, though they were long strings and I didn't notice the difference in the small window. Once I used "git remote -v" and could see the full strings were not the same. Matching them fixed it.
    – ScottSto
    Mar 9, 2022 at 13:37
  • It does not work anymore, support for password authentication was removed from GitHub
    – d3vmak
    Aug 31, 2022 at 9:11
44

For Linux users:

git remote rm origin

git remote add origin https://GITHUB_USERNAME:PERSONAL_ACCESS_TOKEN@github.com/GITHUB_USERNAME/REPO_NAME.git

generate new token

3
  • 8
    This worked for me, except I had to replace the PASSWORD with an ACCESS_TOKEN. You can generate the ACCESS_TOKEN by going to Github > Settings > Developer Settings > Personal Access Tokens > Generate New Tokens. Give it a name and check REPO.
    – Caio Mar
    Nov 12, 2021 at 16:07
  • Works on Windows as well. Keep in mind password support was removed August 2021, so you need to use the access token
    – Blueriver
    Feb 19, 2022 at 12:29
  • This worked nice and perfect! Nov 7, 2022 at 14:29
33

On Windows:

  1. Go to .git folder
  2. Open 'config' file using notepad or any other editor
  3. Change your URL from https://github.com/username/repo_name.git to https://username:password@github.com/username/repo_name.git

Save and Push the code, it will work.

4
26

On Mac

If you are trying to clone the repo.... Then this problem is may occur because you don't have repo present in the github account present in Keychain Access. For resolution try to clone with the account name like

git clone https://username@github.com/org/repo.git

Replace

  • username with your GitHub username
  • org with yours organisation name
  • repo with repository name
1
  • Note that this is deprecated and will soon no longer work. Follow this guide for more information github.blog/… Feb 26, 2021 at 14:12
20
  • Could happen if you have no write access but only read.

  • If it's a private repository you should be added as a collaborator.

  • Check your credentials are correct.

Git won't actually say these things, it would just say that with your credentials no repo was found.

Good luck.

0
19

In my case none solution above worked.

I solved it by switching remote.origin.url from https to ssh:

verify git configuration:

git config --list

should be like:

...
remote.origin.url=https://github.com/ORG/repo-name.git
...

update remote.origin.url with ssh to be used:

git remote set-url origin git@github.com:ORG/repo-name.git
2
  • same. ssh documentation should mention this.
    – Brian D
    Feb 21, 2020 at 22:40
  • Work for me in windows 10 !! Nov 6, 2022 at 9:03
18

For Mac

Open KeyChain Access and find your pssword account on password category ( you can search it on top right keychain access page)

when you find it , delete all keys related to your git source control. and try it again

enter image description here

1
  • 3
    I tried several solutions and this is the one that helped! I had more than one git account, so it seems it was trying to use a different one! Nov 8, 2019 at 18:13
17

The problem here is windows credentials manager, Please goto control panel and search for credentials manager and delete all contents of it regarding github

0
15

You might be logged in with some other GitHub credentials before. Exactly that's why this error is happening.

Usually, mac is storing your GitHub credential to the keychain access tool. Your previous git account details are there. So it is getting mismatched with your current git repo which is in other accounts.

The solution is simple and straight forward,

  1. Go to keychain access in your mac.
  2. On the left side under the category you can find all items. Click that.
  3. Right side top search "git".
  4. You will get some items regarding Github.
  5. Delete all those items.

That's it, here you go.

Try to push again. It will ask you the git username and password. Your new credentials will be stored again in the keychain and your push will be done.

Hurray!

Revert back to me, If you need more help.

Thanks

1
  • This does not work for me. I get the exact same error
    – Alex
    Feb 8, 2022 at 8:24
15

While the previous replies offered various solutions, I found that the easiest one of them is to add the username to the repository's URL

git remote add origin https://your-username@github.com/your-username/repository-name.git

In case you have already defined the repository (without adding the username) you can update it as follows,

git remote set-url origin https://your-username@github.com/your-username/respository-name.git

When pushing to the remote repository git won't pull the credential of any other existing repository from the credential helper, but will ask for the user's/repository's specific password defined in the URL.

As a general note, I'd avoid to use your account's password at all cost and use a personal access token instead. Log in to github and select,

Settings > Developer Settings > Personal Access Tokens > Generate new token

Just make sure to check repo when defining the token's scope and enter the token (instead of your personal password) when asked for a password.

1
  • 2
    In my case I have multiple github user names, so using your-username@github.com in the URL fixed it. Thanks Aug 20, 2021 at 6:06
9

In our case it was simply a case of giving write rights in github. Initially the user had only read rights and it was giving this error.

1
  • 1
    like I have no idea how this only has (now) 3 upvotes..... Jan 11, 2021 at 19:44
7

Disable GIT credential has helped me:

git config --global --unset credential.helper
6

I had the same issue after I set up 2FA on my repo. If you recently set up 2FA on your account, here's what I did to solve it:

Generate a personal access token

Go to Settings -> Developer Settings -> Personal Access Tokens on your GitHub account. Generate a new personal access token. Make sure to check all repo-access related permissions.

Delete all GitHub authentication configuration (from keychain for Mac)

You'll need to sign in afresh using the generated Personal Access Token, so clear all previous authentication details from your laptop. For mac, open keychain and delete all github.com related details from the login/passwords section.

Sign in to your terminal with your GitHub username and PAT as password.

If you've set up 2FA on your account, you won't be able to authenticate using your GitHub password from the terminal. Now, attempt to push to a GitHub repo to trigger a need for authentication. A request to enter your GitHub username will pop up on your terminal. Enter your username, and when prompted for a password, use the generated Personal Access Token as password.

These exact steps solved the problem for me.

0
6

I'm facing same issue and resolving through

git add .

git commit -m "message"

git remote set-url origin https://YOUR_GITHUB_USER@github.com/aceofwings/RotairERP.git

then

git pull
1
  • i really didn't expect this to work....but it did.
    – smoore4
    Apr 7, 2022 at 22:06
6

I tried everything until I realized the repository owner gave me only READ permissions, so Git would throw "remote: Repository not found".

6

I use the gh commandline tool (it's amazing, by the way)

In my case, I was logged in to a different github account. I just needed to run:

gh auth logout
gh auth login

and then go through the authentication flow with the right acount.

1
  • Thanks for the tip, I wish I knew earlier that CLI exist
    – Closery
    Nov 19, 2021 at 13:10
5

So your url currently looks like this below

https://github.com/RevanthM/Log_Monitoring

It needs to look like this

https://RevanthM@github.com/RevanthM/Log_Monitoring

The difference is at the beginning of the url i added my github username followed by a @ symbol.

1
  • this has worked for both visual studio and visual studio code. I think this happened after i installed Git for visual studio code after i already had been using Visual Studio with default / integrated Git Manager.
    – hanzolo
    May 31, 2022 at 15:34
5

in my case, i cannot clone github due to user is wrong.

go to ~/.gitconfig then try to remove this line of code (just delete it then save file).

[user]
    name = youruser
    email = youruser@domain.com

or try to use one liner in your cmd or terminal : git config --global --remove-section user

and try to do git clone again. hope it'll fix your day. ><

5

Solution for this -

Problem -

$ git clone https://github.com/abc/def.git
Cloning into 'def'...
remote: Repository not found.
fatal: repository 'https://github.com/abc/def.git/' not found

Solution - uninstall the credential manager -

abc@DESKTOP-4B77L5B MINGW64 /c/xampp/htdocs
$ git credential-manager uninstall

abc@DESKTOP-4B77L5B MINGW64 /c/xampp/htdocs
$ git credential-manager install

It works....

5

Executing git remote update works for me.

1
5

Some times ssh credentials are setup on your pc to communicate with github repos. When you setup new repo: if you add origin in https format, your git credential manager can't figure-out the repo.

check origin format

git remote -v

Origin in https format

origin  https://github.com/username/repo_name.git

Origin in ssh format

origin git@github.com:username/repo_name.git

Remove origin in https format

git remote remove origin

Add origin in ssh format

git remote add origin git@github.com:username/repo_name.git
5

If you are using access key, please give the appropriate permissions while creating access key (I tried with all the permissions and it works)

4

You are probably trying to push to a private repository. In that case, you will have to ask the admin for Collaborator access to be authenticated.

4

If you are on windows got to control pannel -> windows Credentials then remove github credential from generic credential option. Then try to clone

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.