Git - remote: Repository not found
Asked Answered
D

66

480

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.

Diarmid answered 14/6, 2016 at 13:31 Comment(12)
Are you sure this fails only with git push -f, but works with a regular push, pull and fetch?Callahan
Possible duplicate of Git Push ERROR: Repository not foundKinnon
In my case, I got this error with git clone 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.Crossman
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://mcmap.net/q/81066/-how-to-change-github-account-on-tortoisegitStorybook
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.Bluestone
kevin_theinfinityfpnd 's answer worked for me. Thanks.Elytron
gh auth loginDarondarooge
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.Cosmos
for me, i had to check Settings -> Developer settings -> Personal access tokens and confirm repo (Full control of private repositories)Pandit
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.Gustie
For anyone using personal access token, you can add it manually: git remote set-url origin https://[email protected]/your-repo.gitOnto
You can use GitHub Desktop.Bedel
Z
484

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.

Zicarelli answered 29/10, 2018 at 14:15 Comment(15)
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.Greeneyed
"ALL" means all. Even if it says "web"Crt
For Mac, if you see multiple items/rows related to github, remove all except the one you are trying to pull/push/clone.Deodorant
uhhh, beware this maneuver. I now cannot authenticate at all from the command line, even to repos that were working perfectly beforeSepulchral
Can you share me For ubuntu?Extremadura
Yes, it's work for me, I clean only github credencials, after that, on Teminal(Mac) I input againDionysus
what about linux ?Parthena
TNX! Search on mac Keychain Access in thee spotlight search.Hipped
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 @ZeeshanDorcus
I am unable to delete it, I press delete button, nothing happened (from my macbook)Stoffel
It didn't work even after I deleted all the keychain password associated with github.comFidge
This des not work for me. I get the exact same error, after removing github.com from keychain.Frontwards
thank you! i did exactly that, removed all Git related files in KeyChain access, it worked!Knife
Works for Windows... needed after I changed github accounts for VS on Win10Sharonsharona
After multiple things, I have tried. This works for me!! ThanksIndiscrete
D
322

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

Doran answered 14/6, 2019 at 13:3 Comment(6)
Great answer! I'll just add that in most cases deleting only the "problemtic" line should suffice. No need to delete them all.Heliograph
In my case, I just edited the credentials for Git. Set Github email as username and password. And it worked.Frosted
You can also edit the credentials in the keychain to the current Github account. It also worksAlkalify
I have nothing related to git there.Malchy
thank you this was driving me crazy! I deleted my related profiles and was able to log in again and it worked!Dragonroot
Correct Mukesh...!Meow
R
129

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
Restivo answered 27/10, 2017 at 9:34 Comment(10)
git: 'credential-manager' is not a git command. See 'git --help'.Donetta
@Donetta Please see the Zeeshan Ansari's answer.Erfert
so much search online. and this is the one that work for meSwithbart
removal failed. U_URemanence
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.Crossman
Doesn't work on windows for me, gives all sorts of errors...Malchy
Worked for me on Windows, very helpful answerFadeout
on Ubuntu 20.04, $ git credential-manager uninstall git: 'credential-manager' is not a git command. See 'git --help'.Confessional
Thanks. It's work for me in Windows.Bourassa
Windows version (actually cross-platform): github.com/git-ecosystem/git-credential-manager/blob/release/… I was going to add this as an answer but there's already way too many :)Decastro
W
110

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.

Wolfgang answered 3/12, 2016 at 16:31 Comment(5)
In few casses, GitHub returns repo not found message which you don't have rights instead of permissions not granted.Edith
This was the case for me. Hope they can have a better error message than this.Cohdwell
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.Pham
this should be answer number 1, easy fix and no messing with any local git settingsDumdum
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.Bluestone
I
98

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

and then,

git add .
git commit -m "initial commit"
git push origin master
Irresistible answered 14/6, 2016 at 14:1 Comment(5)
If you are using SSH, you will need to set-url like this: [email protected]:MyRepo/project.gitHoracehoracio
This one actually worked. The credential manager "answers" had no effect for me. Thank you.Heartsome
@Horacehoracio 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 FergusEpithelium
This one works for me as easy as simple, thank you for this simple answerNahum
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.Mohler
C
87

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

Cost answered 16/12, 2021 at 12:7 Comment(6)
That did work once, but now not anymore. Even with a token with all possible rights, I cannot push to my own githubFrontwards
@Alex, have you checked the token life-time ? It might be only a week or 30 days... Take a look at my Update.Cost
Of course, I even created a new token with all rights and used that like 1 minute later.Frontwards
@Alex, might it be the problem with smth. else besides the PAT ?Cost
For me it worked: git remote set-url origin https://[email protected]/<user>/<repo>.git Where the env variable GITHUB_ACCESS_TOKEN is set to the github tokenAffidavit
This is the true answer. You need the access token as part of the URL.Harbor
A
65

For Linux users:

git remote rm origin

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

generate new token

Armstead answered 6/10, 2020 at 17:37 Comment(5)
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.Hakim
Works on Windows as well. Keep in mind password support was removed August 2021, so you need to use the access tokenPainstaking
This worked nice and perfect!Flavour
@Armstead no need user username when adding the github usernameKahlil
Worked for me i'm using Mint Linux.saved my Day bro.ThanksUlani
R
53

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.

Rogers answered 19/4, 2019 at 12:42 Comment(7)
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.Snuff
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 sinceSappy
Same. Add username to the url to fix it in Sourcetree.Roadhouse
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.Haggerty
It does not work anymore, support for password authentication was removed from GitHubCompatriot
Remember you'll get a prompt on VSCode for adding your password. But you have to add your PAT instead. Thanks!Urania
in my opinion, this is the cleanest and most secure option.Benilda
G
37

On Windows, Mac and Linus too:

  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

instead of password you can paste the access token as well.

Save and Push the code, it will work.

Grunberg answered 1/9, 2020 at 21:4 Comment(5)
This works for linux too !Tatterdemalion
Yes, ideally it should! @SujayKunduGrunberg
thanks, works with me for mac alsoVaporetto
Support for password authentication was removed on August 13, 2021Rabbinical
This is what worked for me on macOS. It was the only thing that would trigger a request for the new access token. Thanks!Greeneyed
C
33

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
Constituent answered 5/4, 2020 at 7:25 Comment(1)
Note that this is deprecated and will soon no longer work. Follow this guide for more information github.blog/…Thermobarometer
S
20

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
Sweatbox answered 25/10, 2018 at 10:22 Comment(2)
same. ssh documentation should mention this.Czerny
Work for me in windows 10 !!Chelyuskin
P
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.

Parbuckle answered 2/7, 2019 at 3:20 Comment(0)
L
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

Leonoraleonore answered 13/3, 2018 at 15:12 Comment(0)
T
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

Torrence answered 25/9, 2019 at 11:23 Comment(2)
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!Cookhouse
There's nasty bug in this user interface as described here: apple.stackexchange.com/a/344380/23060 If you find the delete menu option does nothing. Try doing it a different wayReindeer
S
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 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.

Sappy answered 6/4, 2021 at 14:0 Comment(1)
In my case I have multiple github user names, so using [email protected] in the URL fixed it. ThanksAsdic
M
16

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

Matheny answered 14/7, 2020 at 5:49 Comment(1)
This does not work for me. I get the exact same errorFrontwards
W
10

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.

Whisenhunt answered 6/11, 2021 at 7:52 Comment(2)
Thanks for the tip, I wish I knew earlier that CLI existEras
And now you can have multiple accounts and switch between them, instead of logging in/out every time: github.blog/changelog/…Sherrell
C
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.

Corinacorine answered 15/7, 2020 at 13:22 Comment(1)
like I have no idea how this only has (now) 3 upvotes.....Sorb
F
8

Disable GIT credential has helped me:

git config --global --unset credential.helper
Fluency answered 25/3, 2020 at 7:30 Comment(0)
K
7

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

Kookaburra answered 17/8, 2022 at 14:6 Comment(0)
F
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.

Femme answered 15/5, 2019 at 3:10 Comment(0)
P
6

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
Puckery answered 7/12, 2020 at 11:13 Comment(1)
i really didn't expect this to work....but it did.Soluble
C
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 [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
Catron answered 24/6, 2021 at 5:45 Comment(1)
Speaking of SSH, you can test your connection with this command: ssh -T [email protected]. 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!)Reindeer
S
6

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

Shipowner answered 18/7, 2021 at 19:26 Comment(0)
E
5

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.

Evadne answered 9/7, 2018 at 21:32 Comment(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.Telescopy
S
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 = [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. ><

Sikhism answered 1/7, 2019 at 10:50 Comment(0)
P
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....

Planchette answered 6/6, 2020 at 1:45 Comment(0)
U
5

Executing git remote update works for me.

Urus answered 2/9, 2020 at 11:29 Comment(1)
Please add more explanation.Belldas
D
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)

Dunkle answered 15/8, 2021 at 16:15 Comment(0)
E
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.

Effusion answered 27/12, 2016 at 20:25 Comment(0)
C
4

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

Cog answered 31/8, 2020 at 12:30 Comment(0)
T
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

Trapeze answered 25/11, 2021 at 12:2 Comment(0)
P
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.

Pig answered 14/10, 2020 at 9:51 Comment(1)
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!Cheryllches
S
3

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

Switchback answered 15/6, 2021 at 8:24 Comment(0)
M
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

Miscellany answered 2/2, 2022 at 4:30 Comment(0)
F
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/).

Fedora answered 14/6, 2016 at 14:6 Comment(0)
N
2

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
Nubianubian answered 31/1, 2023 at 13:50 Comment(0)
C
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://[email protected]/USERNAME_OF_REPOSITORY_OWNER/PROJECT_NAME.git
Chelyuskin answered 13/2, 2023 at 6:22 Comment(0)
V
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

Volcanism answered 23/5, 2019 at 2:13 Comment(0)
H
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.

Hollinger answered 18/2, 2021 at 0:24 Comment(0)
H
1

Try this, it worked for me.

git remote rm origin
git remote add origin https://github.com/your-username/{{project-name}}.git
Herzl answered 1/3, 2021 at 12:31 Comment(0)
C
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.

Crossbred answered 8/3, 2022 at 20:27 Comment(0)
S
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.

Stoical answered 14/5, 2022 at 6:21 Comment(0)
E
1

In case of authentication issue :

git config --global --unset user.name
git config --global --unset user.username
git config --global --unset [email protected]
git config --global --unset user.token

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

 rm ~/.git-credentials
Exarate answered 14/7, 2023 at 11:53 Comment(0)
D
1

In my case, I needed to add a new SSH/GPG Key to Github. After adding that, the simple solution of pushing to origin worked for me.

I'm on windows and using the command ssh-keygen -t ed25519 -C "[email protected]" for generating it. The output is generated at %USERNAME%.ssh

Domela answered 15/12, 2023 at 18:11 Comment(0)
L
1

On Mac M2 Silicon Chip

I tried everything but nothing worked for me.

  1. Just download GitHub desktop app.
  2. Signin using the account which has access to the repo that you want to clone.
  3. Once the cloning is done open the repo in VSCode and it will work fine from there.
Loriannlorianna answered 8/1 at 9:46 Comment(0)
H
0

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

Hwu answered 23/10, 2018 at 3:17 Comment(0)
C
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.

Corrugate answered 6/11, 2018 at 18:35 Comment(2)
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.Howl
yes you are right here, but I've spent many days looking for same problem solution with ssh. and this topic is closed unwisely #10116873Corrugate
M
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 }
Mandie answered 4/3, 2019 at 14:48 Comment(0)
B
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.

Baggywrinkle answered 4/3, 2019 at 18:2 Comment(0)
Z
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.

Zeta answered 6/3, 2019 at 6:4 Comment(1)
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.Snuff
I
0

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

Isatin answered 1/8, 2019 at 19:9 Comment(0)
J
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!

Jerad answered 15/8, 2019 at 11:58 Comment(0)
N
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

Njord answered 25/11, 2019 at 1:5 Comment(0)
S
0

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

Skirling answered 21/12, 2019 at 14:35 Comment(0)
C
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.

Cd answered 3/4, 2021 at 6:10 Comment(0)
E
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

Epenthesis answered 2/2, 2022 at 9:51 Comment(0)
E
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

Enneastyle answered 9/5, 2022 at 6:53 Comment(0)
I
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

Instinct answered 28/8, 2022 at 22:31 Comment(0)
H
0

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

Hypogeous answered 8/9, 2022 at 7:2 Comment(0)
D
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.

Dysgraphia answered 14/10, 2022 at 3:56 Comment(0)
P
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

Preachy answered 11/7, 2023 at 15:33 Comment(0)
L
0

I have two GitHub accounts on my laptop and local git and everything is okay. when want to add a URL you should set which account you want to use. you can specify the account by adding the username of the account at the beginning of url. sample:

git remote set-url origin https://[email protected]/org/repo.git
git clone https://[email protected]/org/repo.git
Lavern answered 4/10, 2023 at 18:35 Comment(0)
S
0

This usually works for me.

git clone https://@github.com//.git

This tends to work better than

git clone https://:@github.com//.git

because you get a prompt to login to your github.

Streaming answered 11/1 at 20:38 Comment(0)
S
0

If using GitHub CLI, use

gh auth refresh

This will ask you if you'd like to "Authenticate Git with your GitHub credentials? Y/n" Select yes, copy the code it gives you, press enter, and paste the code in the window that opens.

After the authentication is complete, try git push again.

I for sure had the correct account selected and logged in, but the credentials seemed to be mistaken for another account that I have logged in. Anyway, this fixed it nicely.

Sleep answered 1/3 at 3:23 Comment(0)
N
-1

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

Null answered 28/11, 2022 at 4:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.