426

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.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • Are you sure this fails only with `git push -f`, but works with a regular push, pull and fetch? – everton Jun 14 '16 at 14:00
  • Possible duplicate of [Git Push ERROR: Repository not found](http://stackoverflow.com/questions/10116373/git-push-error-repository-not-found) – Michael Freidgeim Mar 01 '17 at 03:58
  • In my case, I got this error with git clone https://github.com/privaterepo. I started to enter a new question as it had nothing to do with SourceTree or git push, but the question itself is perfectly general already. – J. Gwinner Mar 16 '21 at 17:15
  • In case of access related issue or probably you are logged into a different account in your local Git-Client, check this clean solution here - https://stackoverflow.com/a/52816828/515976 – Avisek Chakraborty Aug 30 '21 at 07:38
  • 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. – kevin_theinfinityfund Aug 30 '21 at 21:55
  • 1
    kevin_theinfinityfpnd 's answer worked for me. Thanks. – ashishn Oct 17 '21 at 15:39
  • `gh auth login` – Henshal B Nov 12 '21 at 10:34
  • 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. – Puneet Lamba Dec 05 '21 at 03:04
  • for me, i had to check `Settings -> Developer settings -> Personal access tokens` and confirm `repo (Full control of private repositories)` – Jithin Joseph Dec 11 '21 at 06:26
  • I was getting the same issue, I had a private repo in my work account while I pushed the code from my personal git account. – observer May 28 '22 at 12:10
  • For anyone using personal access token, you can add it manually: `git remote set-url origin https://personal-access-token@github.com/your-repo.git` – Oded Ben Dov Jan 08 '23 at 20:03
  • You can use GitHub Desktop. – SUDHIR KUMAR Feb 27 '23 at 12:18

61 Answers61

440

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.

rlandster
  • 7,294
  • 14
  • 58
  • 96
Zeeshan Ansari
  • 9,657
  • 3
  • 26
  • 27
  • 22
    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 '19 at 01:44
  • 6
    "ALL" means all. Even if it says "web" – Max May 18 '19 at 21:07
  • For Mac, if you see multiple items/rows related to github, remove all except the one you are trying to pull/push/clone. – Shiva Oct 15 '19 at 10:21
  • 9
    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 '20 at 15:41
  • 3
    Can you share me For ubuntu? – Kannan T Nov 06 '20 at 12:22
  • Yes, it's work for me, I clean only github credencials, after that, on Teminal(Mac) I input again – Bruno Jan 19 '21 at 13:05
  • 2
    what about linux ? – Digao Mar 26 '21 at 18:55
  • TNX! Search on mac Keychain Access in thee spotlight search. – Shay Elbaz Apr 25 '21 at 15:50
  • 1
    Guys this did work because the keychain password can sometimes remember a password from a different github account and once you delete that from keychain (mac) the first time you push it will ask for username and pass and then like magic it will work and the pass will get updated in keychain, thank you @Zeeshan – Blu3 Jun 05 '21 at 22:04
  • I am unable to delete it, I press delete button, nothing happened (from my macbook) – RainCast Nov 07 '21 at 23:48
  • It didn't work even after I deleted all the keychain password associated with github.com – DeGi Dec 04 '21 at 15:17
  • This des not work for me. I get the exact same error, after removing github.com from keychain. – Alex Feb 08 '22 at 08:25
  • thank you! i did exactly that, removed all Git related files in KeyChain access, it worked! – lycheelichi May 08 '23 at 04:58
280

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

Mukesh Salaria
  • 3,345
  • 1
  • 16
  • 21
126

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
Marijke
  • 153
  • 3
  • 14
Ajay
  • 1,441
  • 1
  • 9
  • 5
108

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.

Mauget
  • 1,183
  • 1
  • 7
  • 7
  • 7
    In few casses, GitHub returns repo not found message which you don't have rights instead of permissions not granted. – Imran Javed Oct 24 '18 at 17:10
  • 4
    This was the case for me. Hope they can have a better error message than this. – madu Jan 07 '21 at 02: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. – j3141592653589793238 Mar 12 '21 at 11:19
  • this should be answer number 1, easy fix and no messing with any local git settings – Andrei Jun 17 '21 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. – kevin_theinfinityfund Aug 30 '21 at 21:55
82

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
Emre Bolat
  • 4,316
  • 5
  • 29
  • 32
  • 19
    If you are using SSH, you will need to set-url like this: git@github.com:MyRepo/project.git – Fergus Apr 28 '18 at 16:57
  • This one actually worked. The credential manager "answers" had no effect for me. Thank you. – Bobdabiulder Mar 31 '21 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 '22 at 05:51
  • This one works for me as easy as simple, thank you for this simple answer – DL Studio Apr 13 '23 at 22:38
  • This solution should generally work, but occasionally, it may be necessary to remove the GitHub credentials from the Credential Manager for Windows users or Keychain Access for Mac users. – Rehan Shakir Jul 19 '23 at 05:29
69

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

Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69
  • 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 08 '22 at 08:43
  • @Alex, have you checked the token life-time ? It might be only a week or 30 days... Take a look at my **Update**. – Igor Savinkin Feb 09 '22 at 13:21
  • Of course, I even created a new token with all rights and used that like 1 minute later. – Alex Feb 09 '22 at 14:57
  • @Alex, might it be the problem with smth. else besides the PAT ? – Igor Savinkin Feb 10 '22 at 15:35
  • For me it worked: git remote set-url origin https://$GITHUB_ACCESS_TOKEN@github.com//.git Where the env variable GITHUB_ACCESS_TOKEN is set to the github token – villamejia Oct 27 '22 at 21:04
  • This is the true answer. You need the access token as part of the URL. – h0r53 Oct 28 '22 at 16:00
52

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

uber
  • 4,163
  • 5
  • 26
  • 55
  • 9
    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 '21 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 '22 at 12:29
  • This worked nice and perfect! – Ismael Terreno Nov 07 '22 at 14:29
  • @uber no need user username when adding the github username – johnson Jul 07 '23 at 16:43
49

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.

Bharathan Kumaran
  • 981
  • 10
  • 22
  • 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. – Mark Lummus May 03 '19 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 – Bobbie E. Ray Apr 06 '21 at 14:22
  • Same. Add username to the url to fix it in Sourcetree. – KulaGGin Apr 16 '21 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 09 '22 at 13:37
  • It does not work anymore, support for password authentication was removed from GitHub – d3vmak Aug 31 '22 at 09:11
  • Remember you'll get a prompt on VSCode for adding your password. But you have to add your PAT instead. Thanks! –  Oct 12 '22 at 03:48
34

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.

Akshay Sahai
  • 2,121
  • 1
  • 17
  • 20
28

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
sawan nirala
  • 416
  • 4
  • 6
  • Note that this is deprecated and will soon no longer work. Follow this guide for more information https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ – Peter Wauyo Feb 26 '21 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.

Razzlez
  • 526
  • 5
  • 11
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
ModX
  • 829
  • 7
  • 10
18

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

Thirumoorthi
  • 508
  • 1
  • 6
  • 13
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

mohsen
  • 4,698
  • 1
  • 33
  • 54
  • 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! – Juan Giorello Nov 08 '19 at 18:13
  • There's nasty bug in this user interface as described here: https://apple.stackexchange.com/a/344380/23060 If you find the delete menu option does nothing. Try doing it a different way – Harry Wood Jun 26 '23 at 15:47
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

Dhevendhiran M
  • 994
  • 2
  • 12
  • 29
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.

Bobbie E. Ray
  • 635
  • 7
  • 8
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.

user2346968
  • 91
  • 1
  • 3
8

Disable GIT credential has helped me:

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

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.

BananaNeil
  • 10,322
  • 7
  • 46
  • 66
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.

Victor
  • 319
  • 4
  • 5
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
Syed Tabish Ali
  • 309
  • 3
  • 5
6

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
AHL
  • 493
  • 5
  • 8
  • Speaking of SSH, you can test your connection with this command: `ssh -T git@github.com`. Pay attention to the user name it shows you in the response message. It's possible you might get this "Repo not found" error if you have two different user accounts and it starts SSHing with the wrong one (Well that was my stupid problem at least!) – Harry Wood Jun 26 '23 at 15:54
6

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

Julio S.
  • 944
  • 1
  • 12
  • 26
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.

Revanth Matha
  • 69
  • 1
  • 5
  • 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 '22 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. ><

Anthony Kal
  • 2,729
  • 1
  • 20
  • 18
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....

Rohit Saini
  • 685
  • 6
  • 13
5

Executing git remote update works for me.

Ariel Magbanua
  • 3,083
  • 7
  • 37
  • 48
Ashish Jha
  • 281
  • 4
  • 2
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)

Ahmad Ali
  • 148
  • 2
  • 10
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.

Marco V
  • 2,553
  • 8
  • 36
  • 58
4

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

abhinav kumar
  • 1,487
  • 1
  • 12
  • 20
4

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

note:

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

and delete the <> characters

rnewed_user
  • 1,386
  • 7
  • 13
4

NO NEED TO REMOVE EXISTING CREDENTIALS FROM CREDENTIAL MANAGER

All you need is an addition of your github username@ before github.com to your clone command like mentioned below:

git clone https://username@github.com/MyRepo/MyProject.git

an authentication prompt will appear from where you have to sign in to your github account, authentication will succeed and your repo will be cloned .

I was having this issue for a long time and didn't get the exact solution for it until I got to understand the configuration system of Git.

Git used to link a specific github account credentials to a repository, means you can initialize only one github/gitlab account per repository in order to push/pull any changes to your remote origin of the repository which totally makes sense.

And another caveat to keep in mind is whether you're setting a username and email locally or globally while setting up the git config (I'd prefer to keep my username and email local as per repository cause I have to work with multiple accounts on the same machine i.e one personal account, another for workplace) or you're gonna end up committing as an unexpected username which can potentially expose your email if you're doing freelance work sitting on your office couch .

Shoaib Khalil
  • 1,874
  • 17
  • 10
3

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.

ARKhan
  • 1,724
  • 22
  • 30
  • This was definitely part of my issue. VSCode was blocking the login prompt. Also don't forget that Github started blocking password access as of August 2021. You now have to generate a personal token! – Ian Newland Nov 06 '21 at 00:21
3

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

bvsaker
  • 51
  • 5
2

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

rewritten
  • 16,280
  • 2
  • 47
  • 50
2

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

2

It works for me on Linux UBUNTU OS machine. I hope it will work for you as well.

git config --system --unset-all credential.helper


git remote set-url origin https://USERNAME_OF_CONTRIBUTOR@github.com/USERNAME_OF_REPOSITORY_OWNER/PROJECT_NAME.git
Syscall
  • 19,327
  • 10
  • 37
  • 52
Kartik Chandra
  • 390
  • 4
  • 9
1

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

Cameron McKenzie
  • 3,684
  • 32
  • 28
1

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.

Fakhar Ahmad Rasul
  • 1,595
  • 1
  • 19
  • 37
1

Try this, it worked for me.

git remote rm origin
git remote add origin https://github.com/your-username/{{project-name}}.git
Utkarsh Singh
  • 347
  • 3
  • 10
1

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.

1

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.

Rubel
  • 1,255
  • 14
  • 18
1

MacOs

Using VS Code and a key with no password:

  1. removed eval "$(ssh-agent -s)" line from my ~/.zshrc file to stop running it in the background (first step on Github's Generating a new SSH key article)
  2. verified my .ssh/config entry for *.github.com did not have a UseKeychain line
  3. used simply ssh-add ~/.ssh/id_ed25519 with NO --apple-use-keychain
  4. on VS Code "Git: Add remote..." allowed/authorized my Github account connection (you don't really need to add a remote)
  5. applies a new "vscodevscode.github-authentication" entry in Mac's Keychain Access app
  6. closed all shells and VS Code, restarted and the repo is now always found
CPHPython
  • 12,379
  • 5
  • 59
  • 71
0

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

Michael Lihs
  • 7,460
  • 17
  • 52
  • 85
0

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.

Michael Lihs
  • 7,460
  • 17
  • 52
  • 85
Mike
  • 11
  • 1
  • 1
    Snce the git URL in the question is a `https` URL, this will most likely not solve the problem, because ssh keys are not used for HTTPS connections. – Michael Lihs Nov 06 '18 at 18:48
  • 1
    yes you are right here, but I've spent many days looking for same problem solution with ssh. and this topic is closed unwisely https://stackoverflow.com/questions/10116373/git-push-error-repository-not-found – Mike Nov 07 '18 at 07:48
0

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 }
YanSte
  • 10,661
  • 3
  • 57
  • 53
0

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.

Mauro Torres
  • 695
  • 6
  • 6
0

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.

Ankit Sharma
  • 251
  • 2
  • 9
  • there are use cases for using the command line and use cases for using the git desktop app. for instance, there's no way to add tags in the github desktop app. – Mark Lummus May 03 '19 at 19:15
0

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

0

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!

tobiasegli_te
  • 1,413
  • 1
  • 12
  • 18
Nipu
  • 1
0

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 3. Then I could work locally again: Editing, committing and pushing

Achylles
  • 31
  • 4
0

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

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
venkateshwar
  • 39
  • 1
  • 3
0

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.

0

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

lala
  • 2,052
  • 6
  • 24
  • 33
0

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

fzee
  • 65
  • 7
0

It can be an overlapping issue, you're same time config with different account.

Try checking:

git config user.name git config user.email

Check if it's the same with the remote repo.

To check repo git remote -v

0

While cloning from Github in Visual Studio, click on Github link on "Browse a repository" option, it will ask for login. screenshot

umesh shukla
  • 139
  • 3
  • 13
0

Make sure you have right access rights, This can happen when the branch is protected.

I just wasted four productive hours hustling with this.

reconov
  • 45
  • 1
  • 8
0

Update the username and token inside the .git directory.

  • Go to the git folder and go inside the .git folder Open 'config' file

  • using notepad or any other editor Change your URL from

  • https://github.com/username/repo_name.git to https://username:token@github.com/username/repo_name.git

  • username should be without @domain name.

  • Save and Push the code, it will work.

  • Here, you need to save the password and security threat.

Manoj Gupta
  • 456
  • 4
  • 9
0

I just logged out and logged in again using gh auth login. After login selected "preferred protocol for Git operations - HTTPS" As was written in instruction. And it helped. Here is the instruction

Black Beard
  • 1,130
  • 11
  • 18
0

In case of authentication issue :

git config --global --unset user.name
git config --global --unset user.username
git config --global --unset user.your_mail@mail.com
git config --global --unset user.token

You'll need also to remove ~/.git-credentials

 rm ~/.git-credentials
Badr Bellaj
  • 11,560
  • 2
  • 43
  • 44