'Git - remote: Repository not found

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.



Solution 1:[1]

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

For mac

Delete the github.com password from the Keychain Access.

For window

Delete the credentials from Credential Manager.

Solution 2:[2]

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

Solution 3:[3]

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

Solution 4:[4]

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.

Solution 5:[5]

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

and then,

git add .
git commit -m "initial commit"
git push origin master

Solution 6:[6]

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://[email protected]/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.

Solution 7:[7]

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:[email protected]/username/repo_name.git

Save and Push the code, it will work.

Solution 8:[8]

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://[email protected]/org/repo.git

Replace

  • username with your GitHub username
  • org with yours organisation name
  • repo with repository name

Solution 9:[9]

  • 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.

Solution 10:[10]

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

Solution 11:[11]

For Linux users:

git remote rm origin

git remote add origin https://GITHUB_USERNAME:[email protected]/username/reponame.git

Solution 12:[12]

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

Solution 13:[13]

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

Solution 14:[14]

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 [email protected]:ORG/repo-name.git

Solution 15:[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

Solution 16:[16]

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.

Solution 17:[17]

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://[email protected]/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://[email protected]/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.

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.

Solution 18:[18]

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.

Solution 19:[19]

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

Solution 20:[20]

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 = [email protected]

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. ><

Solution 21:[21]

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....

Solution 22:[22]

I'm facing same issue and resolving through

git add .

git commit -m "message"

git remote set-url origin https://[email protected]/aceofwings/RotairERP.git

then

git pull

Solution 23:[23]

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 [email protected]:username/repo_name.git

Remove origin in https format

git remote remove origin

Add origin in ssh format

git remote add origin [email protected]:username/repo_name.git

Solution 24:[24]

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

Solution 25:[25]

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.

Solution 26:[26]

So your url currently looks like this below

https://github.com/RevanthM/Log_Monitoring

It needs to look like this

https://[email protected]/RevanthM/Log_Monitoring

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

Solution 27:[27]

Disable GIT credential has helped me:

git config --global --unset credential.helper

Solution 28:[28]

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

Solution 29:[29]

Executing git remote update works for me.

Solution 30:[30]

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.