Error message 'Authentication failed on the git remote' - visual-studio-code

I'm trying to push, pull, and whatever to my GitHub repository from Visual Studio Code.
I enter my username and password, but I'm getting the error:
Authentication failed on the git remote.
I just logged in on github.com with the same user/password.
I tried creating a personal access token, using it as a password, but I got the same error.

I believe I have found a solution to this problem. None of the solutions above worked for me. I think the root cause of this issue is that GitHub has ended support for password authentication on August 13, 2021. Instead a personal access token needs to be used.
The steps to solve this issue are as follows:
Create a personal access token on GitHub.com. Tutorial here
Go back to Visual Studio Code and open terminal. Type in the following command with your own user information:
git remote set-url origin https://<TOKEN>#github.com/<user_name or organization_name>/<repo_name>.git
In case you would like to follow a video guide, this one proved to be quite helpful.

I solved it by following Caching your GitHub password in Git.
The steps are as follows:
Download and install Git for Windows
Run Git Bash, 'cd' to the repository directory and enter git config --global credential.helper wincred

It happened to me after GitHub changed its policy on 13 August 2021 to authenticate using a personal access token (PAT) instead of a password.
I did these steps for myself. I am on Lubuntu 20.04.
Created .gitconfig in my home directory and added the following
[user]
name = {your github username}
email = {your email}
[credential]
helper = store --file ~/.git-credentials
Created .git-credentials in my home directory as you can see above and added the following
https://{your github username}:{your github PAT}#github.com
Final step: Restart your terminal and voilà! Try to commit/push/pull in an existing Visual Studio Code Git folder and everything will work as before.
Security Issue
Your personal access token (PAT) will be exposed as clear ASCII text and can be read if anyone has access to your user account.

I had the same issue with my Visual Studio Code on Linux cloning a Visual Studio Git repository.
It was Solved by setting up the Alternate Authentication Settings under security settings on {your-account}.visualstudio.com
Screenshot:

Configure VS Code Github authentication using Github CLI, gh.
Download and install gh here
After installation, open vs code terminal and login to github with gh auth login
You'll be prompted to choose an authentication method. Available authentication methods are password and personal access token. I'd recommend using a personal access token because your authentication details will be stored in plain text on your local machine. Here is a tutorial on creating a personal access token. You can then generate a personal access token here. Ensure your personal access token have the minimum required scopes repo, read:org, workflow
Paste your personal access token and gh will handle the rest.
If you've gone through the above steps before but your personal access token has expired, you can simply generate another personal access token and paste inside the /home/<user>/.config/gh/hosts.yml file. Note that this file path is for linux/MAC users. Windows users should be able to locate similar path in their filesystem.

In case of using VSCode git graph's buttons that result in message error like this:
Unauthorized fatal: Authentication failed ... unable to fetch from remote(s)
This worked for me:
git remote set-url origin "<the git you want to clone/pull/fetch>.git"
Enter your email & password in VSCode pop-ups
Now you can use git graph or cmd normally again

git remote set-url origin https://USUARIO:SENHA#bitbucket.org/URL.git
worked for me!

I faced a similar problem. I was coding in vs code. So, I just tried another terminal to push my code and it works for me!!

Related

How can I get Visual Studio (Mac) to meet GitHub Token Authentication requirements?

I recently committed to GitHub using Visual Studio for Mac (8.10.6) and got an email:
You recently used a password to access the repository at
with git using git/2.24.3 (Apple Git-128).
Basic authentication using a password to Git is deprecated and will
soon no longer work. Visit
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
for more information around suggested workarounds and removal dates.
I've read that blog post but I cannot see how to make this change for VS. I note that it mentioned git/2.24.3 but from the command-line I see:
$ git --version
git version 2.10.0
$ which git
/usr/local/bin/git
Update
On a new machine, I am indeed prompted for login details and can use a PAT. But I would still love to know where this is stored on disk, or in VS settings, in case I need to change Git user.
You can use personal access tokens. Click on your profile picture on the GitHub page, then on Settings → Personal access tokens → Generate new token. Follow the wizard to select what to grant, at least you'll need to read repo.
On Visual Studio Code you provide your username and for password, you provide the newly generated personal access token.
P.s: Make sure to note down the personal access token somewhere.

VS Code: Get 'Bad credentials' when using Clone Repository

I use vscode version 1.45.1. I get 'Bad credentials' when using Clone Repository. Lately I changed my username at github. That could be the reason. How do I tell vs code that?
You'll need to open up Credential Manager in Windows and delete (or edit) the Github account there:
You'll need to restart Visual Studio Code for it to prompt you to login to Github again.
Also note that you may need to revoke the OAuth connection in Github under https://github.com/settings/applications:

IntelliJ cannot log in to GitHub

For some reason, a new IntelliJ installation is unable to log in to GitHub. (The credentials are correct.)
It happens both when I try to "share project on githu" and "checkout project from version control", select Git and then try to log in to GitHub.
Here's the login prompt:
Server: github.com
Login: <my username>
Password: <my password>
And the error message:
Invalid authentication data. Can't create token:
scopes - [repo, gist] - not IntelliJ Plugin_1 422
Unprocessable Entity - Validation Failed
[OauthAccess; description]already_exists: null
Now, this is on a freshly installed Windows 10 computer, with a freshly installed IntelliJ. So there are no old tokens or anything like that anywhere in the system. This is the first attempt to access GitHub from IntelliJ. Logging in via web works fine.
That kind of error messages can be frustrating, as it takes more than a little knowledge on the subject to understand exactly what is wrong. Usually, however, the problem is either the authentication (invalid username/email/password) or that there's a problem with git (locally).
First of all, check that you have git installed by running "git" from the command prompt. This is a more common mistake than one would think.
Second, try y.bedrov's suggestion. Log in to github.com on the web. Settings -> Developer settings -> Personal access tokens. Create a new token and then, in IntelliJ, select Enter Token at the login prompt.
Tokens are considered a more secure way to authenticate, I believe.
Oh, in case you generated the token from GitHub and are unable to use that in IntelliJ...
Then, go to Settings -> Version Control -> GitHub
In the Login to GitHub popup, click "Use Token" on the top right corner of the popup.
Add your token and enjoy.
When you make first attempt to access GitHub from IntelliJ, you do not have intellij-github authorization in place and also tokens.
So, follow the instructions here to get rid to this issue.
https://www.jetbrains.com/help/idea/github.html#register-account
After this, the project can be easliy shared on github.
In my situation it was because I was behind a proxy and IntelliJ was not able to reach the internet.
To verify whether IntelliJ is able to reach the internet go to Settings>System Settings>HTTP Proxy
Click on check connection and try for example http://google.nl.
I had to set my proxy to Auto-detect so it will use the proxy of Windows.
From my experience, you will have to set the remote of this project, try to find the "Remote..." within the "VCS" tab, then when you set it, IntelliJ will open your default browser and there is a permission check, which is what lead to your error message.
In short, Set remote, Authorize IntelliJ on GitHub Settings.
The issue is that IDE tries to create a token with the name that already exists. Appears to be related with the token name case - see https://youtrack.jetbrains.com/issue/IDEA-198120
As a workaround, navigate to https://github.com/settings/tokens and delete all tokens called IntelliJ Plugin (including those with suffix)
Couple of issues can be there to block you from accessing your github repo and throwing 403 error. Hence please go step by step.
Step-1 : Local git is corrupted or not working
git branch -r [If it gives result you are good]
git ls-remote --heads <remot_git_location>
if one of the above is working then your local git is good. If not use
git config --global --unset credential.helper
Step-2 : From your IDE (IntelliJ or PHPStorm etc) see git is configured and test it.
Go to Default Settings-->GitHub and Your host should be "https://github.com"
Get your Github personal token. Login to your github account from browser. Settings -> Developer settings -> Personal access tokens.
o Select all “repo”, gist and “read.org” in your scope.
o Create the token
Last step: If still not working, Go to VCS--> GIT --> Remotes --> Change the repo to include token explicitly
https://user_name:<your_TOKEN>#github.com/reponame.git
Paste the token in your IDE and test the connection.
If your problem still persists then check if there is network issue.
I have had the same problem to sign up from Android Studio's interface to my GitHub account. At the end what worked is installing Git from VSC tab as this guy said:
https://stackoverflow.com/a/65059893/14715236
But i still not being able to access my account (note: with Login-Password method) so generating token it worked.
I also had the problem with logging to github using Intelij IDE. It shown "invalid authentication data" msg with 404 error. Installing the latest version of the IDE solve that problem.
If you use two factor auth then you need to use an access token.
If you use HTTPs access, after 2-factor authentication is enabled you will need to configure an Access token (BitBucket calls it app password) and use it to authenticate.
https://intellij-support.jetbrains.com/hc/en-us/articles/206537004-How-to-access-GIT-remote-repositories-with-2-factor-authentication
Github has disabled password based auth to api as here https://docs.github.com/en/rest/overview/other-authentication-methods
In my case somehow I was logged out and IDE was showing this error repeatedly instead of login prompt.
So, I just logged in again in setting-> Version Control -> github.
There I saw I was logged out.
After logging in, error was gone and prompt for
Access token was shown when I clicked on git->github on top menu of IDE.
Hope my answer helps you saving some time
Since August 13, 2021. GitHub no longer supports password authentication for git operations. You must generate a token in your GitHub account. Follow
"Settings> Developer Setting > Personal access tokens > tokens (classic)". while generating your token, you must "SET PERMISSION" for your token. Whenever you want to Sign In via Intellij or git terminal, you must enter your username and your token (instead of password) in the password textbox.

Eclipse Git (Egit) not accepting remote username and password

Why doesn't Egit accept username and password when fetching from remote?
These are the steps I follow:
In Git Repositories view I expand Project -> Remotes -> origin
Right click on origin -> fetch
Login mask appears; I insert User and Password
Repeat step 3 other two times
An error message appears: https://companyname.visualstudio.com/.../projectname: not authorized
Credentials are correct and I am authorized because I use them daily with any kind of git interface: TortoiseGit, SmartGit, Git Bash, ...
I did research but didn't find this problem. Also similar questions don't address this problem.
Update: I used a workaround following this guide. I created an access token from the Visual Studio Team Services account and I'm using that as password.
My git installation is using Git Credential Manager (GitHub page, Microsoft guide to GCM) to store credentials, in fact when I ran for the first time git through the interfaces I mentioned above and tried to connect to the Team Services Git repository the Microsoft Account login window popped up and that was it. Also I can tell it from runnig the command git config --list and getting credential.helper=manager.
Eclipse has the Team Explorer Everywhere plug-in installed, so it should interact with Git Credential Manager and accept the Microsoft Account credentials, but it doesn't. So this is still an open issue.
I was facing the same issue
From git side
settings-->developer settings-->Personal access tokens-->generate new token-->copy that token and use that token as password.
The way to fix this is to go to
Window->Preferences->Team->Git
And then change the HTTP client from Apache HTTP to Java Built-in HTTP
The Git clients you mention uses "native" git, and the credentials are provided transparently during the communication with the server.
Eclipse git client (jgit+egit) is full-java based, and unfortunately you can't use native git in Eclipse.
Either your Git server has user+password locally (not so enterprise-ish!) or you could use Kerberos tickets in Eclipse git; but before you run Eclipse you should do a kinit to create a ticket with your user logon, that is accessible from java process. (Normally the ticket is in your user home directory)
Example using kinit:
I m not so sure about the TFS plugin, but maybe in your case it is worth to install it and see if it helps you instead of the embedded egit, see https://msdn.microsoft.com/en-us/library/hh301122(v=vs.120).aspx
I had the same issue, not able to update the username in eclipse pop up while pushing to Git. Irrespective of username, I have provided the generated git credentials password and it worked.
Use personal access token for https. Fine graned tokens are preferred.
Refer. https://cse132.engineering.wustl.edu/files/githubEclipseAuth/githubEclipseAuth.html

Issue with SourceTree while cloning a GitHub repository

I know that similar questions have already been posted here. However, I think my scenario is a bit different. Here is what I have.
I downloaded and installed the latest official version of the SourceTree software. Also, I have a GitHub account with permissions to clone and push the repository. In order to manage a local copy, I need to clone the online version. Here are the steps that I take:
Start the SourceTree and navigate to File -> Clone / New ...
In the opened window I paste the HTTPS clone URL. I copied it from the browser after I logged in to my GitHub account so the link is correct.
The nest step is to specify a local folder where the repository will be copied. However, when I click to enter Destination Path, the window shows an error:
This is not a valid source path / URL
Clicking the error may give the following details:
remote: Repository not found.
fatal: repository 'https://github.com/org/repo.git/' not found
remote: Repository not found.
fatal: repository 'https://github.com/org/repo.git/' not found
Or the details may be empty. SourceTree does not tell me the reason for the error or anything else.
I tried to re-install SourceTree but the error still exists. I asked the Administration of the GitHub repository for any other permissions but my account has all of them. I am able to push changes to the online repository using the Terminal console but I would like to use a UI (that SourceTree provides) to manage and compare changes in the code.
One think I did not try is to clone the repository using another GtHub account. However, I don't want to do that because I need to commit any changes to the repository on my behalf.
Does anybody know how can this error be fixed or worked around?
I was facing the same issue in Sourcetree for macOS:
This is not a valid source path / URL
The following solution worked for me:
Sourcetree > Preferences > Advanced
Remove the Host name
Clone the project again in Sourcetree
A prompt will pop up; enter your git credentials.
That's it, it resolved my issue.
Lastly on Mac I went to
Sourcetree->Preferences->Git->Git version->Use System Git
and it works... puf!
The exact error message is (as illustrated here):
This is not a valid source path / URL
Possible cause:
proxy settings (as in this thread)
setup steps, with Git disabled (as in here)
When SourceTree started for the first time, I skipped setting up Git & Mercurial in the wizard. Then I reran the wizard and chose to download and install the embedded packages.
But it seems installing those didn't actually enable them - in the Tools -> Options dialogue they were both disabled!
Enabling Mercurial (or Git in your case) allowed the clone dialogue to correctly identify the repo.
credential issues (as in here, from my old answwer)
So I'm here in 2021. Previous answers didn't work for me. There is an issue with a SourceTree (to be honest a lot of issues actually) and as a workaround you can use a token as a password to connect to GitHub.
Use this url to create it: https://github.com/settings/tokens
I hope it helps! 🙂
I was facing the same issue with windows 10 and source tree. After bit research following solution worked for me.
I needed to download or enable the git support in source tree.
Steps
1) Go to Tools -> Options -> Git -> Enable git support
That's it it resolved my issue. Happy coding :)
I was facing the same issue in mac. The following solution worked for me :
Generate personal access token in Github using the following steps :
Login to Github account -> Settings -> Developer Settings -> Personal
access tokens -> Generate new token -> Enter token name -> Generate
token
Sourcetree > Preferences > Advanced
Remove the Host name
Clone the project again in Sourcetree
A prompt will pop up; enter your git credentials. (enter username and in
password enter newly generated access token)
After following this steps, Clone option will get enabled
May I also just add that I resolved this issue by installing Git through SourceTree from [SourceTree]>Tools>Options>Git.
As I'd been using mercurial exclusively on that system till then it had never been installed, and so was presenting the above described error when trying to clone.
Hopefully this helps someone with the same issue! If not, good luck!
I was facing the same issue with windows 10 and source tree. After bit research following solution worked for me. I needed to download or enable the git support in source tree.
Steps 1) Go to Tools -> Options -> Git -> Enable git support
That's it it resolved my issue. Happy coding :)
Even tried all the options above, It quite dint work for me.
I disable the option of ssl certificate
steps :
Go to Tools -> Options -> Git. check the box of "Disable SSL certificate validation"
It worked for me.
Open source tree Tools -> Options -> Git -> Update Embedded. While updating it will ask your gitlab account for linking. After that restart your system.
Adding my scenario and solution:
I have two factor authentication turned on. I couldn't see some private repositories, and couldn't clone from URL. The error I saw was:
remote: Repository not found.
fatal: repository 'https://github.com/bizzabo/web-common.git/' not found
remote: Repository not found.
fatal: repository 'https://github.com/bizzabo/web-common.git/' not found
Supposedly newer versions of SourceTree don't need a personal access token because they can authenticate directly with github, but I couldn't get this to work.
Apparently OAuth and 2FA don't mix well together -- so I changed the authentication method from oauth to basic and used the access token I generated. That did it.
Just in case someone who has multiple git accounts connected and faces this issue, I solved it by going to Tools > Options > Authentication and marking the account which has access to the repo you are trying to clone as default.
Install git to your system by browser and then go to the source tree, click on
Tools -> Options -> Git
then scroll down and click on system.
It works for me, I hope for you too.
I had to uninstall and reinstall SourceTree before it would work. I think my antivirus (Comodo ) was blocking/sandboxing some stuff on the initial install so I disabled it for the reinstall.
I had also same issue This is not a valid source path / URL and it got resolved by updating the Embedded Git of Source Tree.
This issue also manifested itself where I couldn't push or pull from previously cloned and working repositories in source tree. I complained about authentication username and password but clearly that was not the case.
Steps to resolve:
Open source tree, Tools -> Options -> Click on Git Tab -> Update Embedded Git.
I had the same problem. My resolution was to commit an initial file into the repo. After that, I could clone the repo to my desktop.
options -->Tools--->disable ssh worked for me in Mac
The issue might be because of SourceTree didn't have all private access from Github
I have answered here please check to avoid the duplicate answer posting reference link
https://stackoverflow.com/a/62145210/4328589
If you are using Mac and there is Keychain access handling all your authentication, then delete the entry for stash/git url. Now try to checkout in sourcetree and it will ask to enter the password again.
That will solve your problem.
I face this issue on Windows 11 and following are the steps worked for me :
Click on Open with GitHub Desktop option [Refer below image]
Download & install
Launch and click on Open in browser with Github.com
Enter your credentials & validate
Now, Open SourceTree
Click on Tools > Options > Authentication
You will see your Git credentials were successfully added in SourceTree & you can proceed with any option like clone repo etc
I was trying to clone a project from gitlab. However, I have cloned gitlab projects earlier with an account/user credentials which is different from the new account I want to use. In this case, I had deleted the credentials for the old account and then I was able to clone the project by entering credentials for the new gitlab account. To delete the account on MAC go to Preferences > Advanced > Select the account to remove > Click remove.
In my case i was doing new Mac book setup.
Without installing Xcode i was trying to clone branch using SourceTree.
After Xcode installation done, branch cloned successfully.
SourceTree asked for system password for cloning.
I'm posting another possible solution, as I just helped a colleague who couldn't clone a private repo belonging to a GitHub organization even though he had been given the correct level of access.
Check the Windows Credential Manager, especially if you've been using the same machine for some time or have connected to different accounts.
Git may be picking up the wrong credentials without you realizing it, and that's why it can't find the repo.
To be on the safe side, delete all the credentials that have to do with git/github. You'll know you have done it properly and are starting from a fresh state when you will try cloning again and git will ask you to authorize it through your browser.
probably you try the wrong account only add this
account.name# to link
you can learn it from your GitLab account
https://account.name#gitlab.com/samrak-growth/samrak-app-backend.git
In my specific case (setting up a new mac) the root cause was a "missing xcrun" meaning the local dev tools wasn't activated, and the local git client can't run properly.
that was my fix
xcode-select --install
In my case I had used SourceTree's "Add account" setting to add my Bitbucket and GitHub accounts to SourceTree under the SSH protocol. SourceTree did everything correctly to generate SSH keys and add them to my machine but it made a slight mess of the entries that it added to my ~/.ssh/config file. It created entries as follows:
Host username-Bitbucket
HostName bitbucket.org
User username
PreferredAuthentications publickey
IdentityFile /Users/adil/.ssh/username-Bitbucket
UseKeychain yes
AddKeysToAgent yes
Host username-GitHub
HostName github.com
User username
PreferredAuthentications publickey
IdentityFile /Users/adil/.ssh/username-GitHub
UseKeychain yes
AddKeysToAgent yes
The Host values it generated are incorrect. I changed the entries in my ~/.ssh/config file to the following:
Host bitbucket.org
User username
PreferredAuthentications publickey
IdentityFile /Users/adil/.ssh/username-Bitbucket
UseKeychain yes
AddKeysToAgent yes
Host github.com
User username
PreferredAuthentications publickey
IdentityFile /Users/adil/.ssh/username-GitHub
UseKeychain yes
AddKeysToAgent yes
After making this change, the "This is not a valid source path / URL" error went away and I was able to clone repositories from my Bitbucket and GitHub accounts without problem.
I removed and added my account again using the HTTPS rather than SSH URL.