Git - remote: Repository not found

GitGithubAtlassian Sourcetree

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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

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

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

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

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

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

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

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

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

For Linux users:

git remote rm origin

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

Solution 11 - Git

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 12 - Git

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 13 - Git

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

Solution 14 - Git

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 15 - Git

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

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

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

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

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

Solution 20 - Git

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

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

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

Solution 23 - Git

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

Solution 24 - Git

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

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

Disable GIT credential has helped me:

git config --global --unset credential.helper

Solution 27 - Git

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

Solution 28 - Git

Executing git remote update works for me.

Solution 29 - Git

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.

Solution 30 - Git

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 31 - Git

I was facing this error in VS code because I was using VS code git extension. It saves my git credentials on Linux key-ring. While I wanted to git pull from another account which has access to the repository. The most simple solution is to open the Linux shell (not the one integrated in VS code) and then run:

git pull origin master

This time, it will ask you the username and password of Github.

Solution 32 - Git

You must generate a new token: here the steps https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

remove control at origin locally

 git remote remove origin

add it again but now with your generated token

git remote add origin https: // <token> @ <git_url> .git

and push it

git pull https://@.git

note:

what is git_url? is the url of your current project example: github.com/yourUser/yourProy

and delete the <> characters

Solution 33 - Git

It is probably a matter of authentication. SourceTree caches your github credentials (that are used to access the repository by https) but from terminal you have to either configure git with the credentials (https://help.github.com/articles/creating-an-access-token-for-command-line-use/) or use git+ssh and a ssh key pair (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/).

Solution 34 - Git

I have faced the same issue in my Windows10 system.

The Problem here is the Username you are having in the system. You can resolve it using

git credential-manager uninstall

git credential-manager install

If it doesn't work then you have to install ubuntu in your system which is available at the App Store.

In that ubuntu terminal, I force push the repository and It worked after asking me the Username and Passwordstrong text

Solution 35 - Git

I was trying to clone a repo and was facing this issue, I tried removing all git related credentials from windows credentials manager after that while trying to clone git was asking me for my credentials and failing with error invalid username or password. This was happening because the repo I was trying to clone was under an organization on github and that organization had two factor auth enabled and git bash probably do not know how to handle 2fa. So I generated a token from https://github.com/settings/tokens and used the github token instead of password while trying to clone the repo and that worked.

Solution 36 - Git

I had other existing github repositories but I mistakenly thought that I could create the repository using git commands. I thought that my problem was not having a Personal Access Token but I was still not able to push using commands below for creating my repository.

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/username/project.git
git push -u origin main

I continually got:

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

in response to

git push -u origin main

However, I found that the repository needed to be created using the github cli or at their github site after logging into my account. Once I did this, everything worked like a charm.

Below is the link where I discovered that I could not create a github repository with git commands.

https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line

Solution 37 - Git

In my case I needed to open the directory on Linux using Ctrl + H to see the hidden documents, so I got into to the Git config and took out the .git in the URL.

Solution 38 - Git

I solved it by deleting the .git file (hidden folder) and then uploading it again.

Solution 39 - Git

I had the same issue and found out that I had another key file in ~/.ssh for a different GitHub repository. Somehow it was used instead of the new one.

Solution 40 - Git

Check if the url s.source is correct.

Example for me

// fail Project>>t<<est
    
s.source = { :git => '.../Projecttest-iOS', :tag => s.version.to_s }
        
// success    Project>>T<<est
s.source = { :git => '.../ProjectTest-iOS', :tag => s.version.to_s }

Solution 41 - Git

For my team it was a permissions issue. In the GitHub settings, it was set to Read mode for all members in our team. Once we changed the drop down to Write, we were all able to clone and push back successfully.

Solution 42 - Git

If you are using Git Desktop application than you should try to push and pull form git desktop app instead of terminal. It will help you.

Solution 43 - Git

I'm seeing this fatal: repository not found error more often now as people try and push and pull from private GitHub accounts on the free tier. These are the most common solutions to the problem:

  • You did not authenticate
  • Your password has changed
  • You are not a collaborator
  • Incorrect case or a word misspelled
  • The git repository has been deleted

Windows Credentials Manager?

Sometimes Windows Credentials Manager caches your u/p and passes it along behind the scenes. If you've changed your password recently, or are using a different username, you might need to go into the credentials manager and clear your existing entries for GitHub.

Fatal Exception

Solution 44 - Git

You can try deleting the .git file in the directory and doing everything again will fix your problem!

Solution 45 - Git

I had the same issue

It was resolved by checking the http.proxy value in git config (mine was incorrect and unwanted), Hence I removed http.proxy value from git config

commands:

List down the config items in the file

git config --list

Remove the proxy

git config --global --unset http.proxy

The problem was solved!

Solution 46 - Git

I also had that issue. To solve that I:

  1. Moved my local .dotfiles away to _.dotfiles_bak
  2. Cloned my remote git repository
  3. Copied all my files from _.dotfiles_bak to .dotfiles - except the .git folder
  4. Then I could work locally again: Editing, committing and pushing

Solution 47 - Git

This happens when the repository, team name or username changes.
There is one solution (that I know): revert the repository name.

Solution 48 - Git

Try this, it worked for me.

git remote rm origin
git remote add origin https://github.com/your-username/{{project-name}}.git

Solution 49 - Git

If repo is private make sure you have accepted the repo invitation. If repo is private without accepting the repo invitaion if you will directly push changes it gives the same error.

Solution 50 - Git

None of the other answers worked for me, and I could view the repo in the browser but got the Not Found error when trying to fetch or do a new clone. For some reason, this fixed it:

  1. Visit Github repo in web browser.
  2. Click on the green "Code" button (picture below).
  3. Select Open with Github desktop.
  4. Github desktop should open and successfully fetch.
  5. You can now close Github desktop and fetch or clone from the console or your Git software of choice.

The green code button

Solution 51 - Git

I faced the same issue but when I found out that I have created the repository from another account and try to push the code from another account. That's it now I just had to give the access to another account and problem solved. You would find to give the access from

Setting > Contributors > Add People

Solution 52 - Git

On ubuntu, I faced this issue. I solved this by resetting credential helper, by running this command below.

git config credential.helper "" 

after running this command, when you pull or push, you will be asked to input your credential again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatrosov OleksandrView Question on Stackoverflow
Solution 1 - GitZeeshan AnsariView Answer on Stackoverflow
Solution 2 - GitMukesh SalariaView Answer on Stackoverflow
Solution 3 - GitAjayView Answer on Stackoverflow
Solution 4 - GitMaugetView Answer on Stackoverflow
Solution 5 - GitEmre BolatView Answer on Stackoverflow
Solution 6 - GitBharathan KumaranView Answer on Stackoverflow
Solution 7 - GitAkshay SahaiView Answer on Stackoverflow
Solution 8 - Gitsawan niralaView Answer on Stackoverflow
Solution 9 - GitRazzlezView Answer on Stackoverflow
Solution 10 - GituberView Answer on Stackoverflow
Solution 11 - GitmohsenView Answer on Stackoverflow
Solution 12 - GitThirumoorthiView Answer on Stackoverflow
Solution 13 - GitModXView Answer on Stackoverflow
Solution 14 - GitIgor SavinkinView Answer on Stackoverflow
Solution 15 - GitDhevendhiran MView Answer on Stackoverflow
Solution 16 - Gituser2346968View Answer on Stackoverflow
Solution 17 - GitBobbie E. RayView Answer on Stackoverflow
Solution 18 - GitVictorView Answer on Stackoverflow
Solution 19 - GitJulio S.View Answer on Stackoverflow
Solution 20 - GitAnthony KalView Answer on Stackoverflow
Solution 21 - GitRohit SainiView Answer on Stackoverflow
Solution 22 - GitSyed Tabish AliView Answer on Stackoverflow
Solution 23 - GitAHLView Answer on Stackoverflow
Solution 24 - GitAhmad AliView Answer on Stackoverflow
Solution 25 - GitMarco VView Answer on Stackoverflow
Solution 26 - GitRadosław AndraszykView Answer on Stackoverflow
Solution 27 - Gitabhinav kumarView Answer on Stackoverflow
Solution 28 - GitAshish JhaView Answer on Stackoverflow
Solution 29 - GitBananaNeilView Answer on Stackoverflow
Solution 30 - GitRevanth MathaView Answer on Stackoverflow
Solution 31 - GitARKhanView Answer on Stackoverflow
Solution 32 - GittitleLoginView Answer on Stackoverflow
Solution 33 - GitrewrittenView Answer on Stackoverflow
Solution 34 - GitThillai MaharajanView Answer on Stackoverflow
Solution 35 - GitFakhar Ahmad RasulView Answer on Stackoverflow
Solution 36 - GitbvsakerView Answer on Stackoverflow
Solution 37 - GitLeonardo Holanda e SilvaView Answer on Stackoverflow
Solution 38 - GitJohn Fabian Timoteo TorresView Answer on Stackoverflow
Solution 39 - GitMikeView Answer on Stackoverflow
Solution 40 - GitYannStephView Answer on Stackoverflow
Solution 41 - GitMauro TorresView Answer on Stackoverflow
Solution 42 - GitAnkit SharmaView Answer on Stackoverflow
Solution 43 - GitCameron McKenzieView Answer on Stackoverflow
Solution 44 - GitKirubel TadesseView Answer on Stackoverflow
Solution 45 - GitNipuView Answer on Stackoverflow
Solution 46 - GitAchyllesView Answer on Stackoverflow
Solution 47 - GitvenkateshwarView Answer on Stackoverflow
Solution 48 - GitUtkarsh SinghView Answer on Stackoverflow
Solution 49 - GitRajkumar ShuklaView Answer on Stackoverflow
Solution 50 - GitlalaView Answer on Stackoverflow
Solution 51 - GitfzeeView Answer on Stackoverflow
Solution 52 - GitRubelView Answer on Stackoverflow