I have scm git installed and GitHub for Windows.
When I try to push I get prompted for username/password then get "Authentication failed on the git remote."
I am able to push from GitHub for Windows and command line using same credentials
What do you get when running git remote -v?
Hi, opening GIT bash in the folder & running I get
$ git remote -v
origin https://github.com/joe912/taggle.git (fetch)
origin https://github.com/joe912/taggle.git (push)
Yeah this is known. Hope you don't mind that I renamed this issue.
GitHub Desktop clones every repository using the https protocol and creates ~/.ssh/github_rsa and ~/.ssh/github_rsa.pub which it somehow uses for auth. git (or ssh) by default only looks for ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub when using authentication.
We need to:
https protocolgithub_rsa key when pulling/pushing from a GitHub repository.ok - thanks for the update
I can confirm I am having this same issue. I can use GitHub Desktop or CLI to push, but I can not sync with VS Code. I tried again with the December update and it was not supported still.
I found the following Stackoverflow post that solved this issue.
Basically, I ran git config --global credential.helper wincred from the command line, and restarted VC Code. When I reopened the project, I was now able to sync from VS Code.
Do not know how this persists, and if it is only for that repo (--global makes me thing it will work elsewhere).
Can we run this command as part of installation, if this solves the issue?
Hello, I'm having the same issues, already followed the Stackoverflow post but it didn't work.
I don't have any problem with editing the code in VSC and then using the CLI or the GitHub desktop to sync my repos but It would be great if this issue is solved, the last update didn't solved it.
thanks
Hi, I'm experience this issue too. I'm willing to help. Please let me know how.
I can elaborate on what is causing issue for people.
If GitHub desktop is opened, it will break VS Code ability to push/pull. Closing GitHub desktop, _DOES NOT_ fix VS Code GitHub sync.
Instead you have to -
git config --global credential.helper wincred from Powershell or Cmd.Opening GitHub Desktop will break this. There seems to be a conflict of some sort that is causing this issue.
@khrome83 I tried several times your workaround and it is not working.
I was having this exact problem. Closing GitHub Desktop and running the config command did nothing for me. I started backtracking and remembered that I had recently added a simple .gitattributes file.
Most of the file was simply comments, and once I removed it and followed the instructions above once again, things started working. Every time I open the desktop app, it breaks again. But at least the aforementioned fix works as long as I don't add this file to the project.
# # Auto detect text files and perform LF normalization
# * text=auto
#
# *.cs text diff=csharp
# *.java text diff=java
# *.html text diff=html
# *.css text
# *.js text
# *.sql text
#
# *.csproj text merge=union
# *.sln text merge=union eol=crlf
#
# *.docx diff=astextplain
# *.DOCX diff=astextplain
#
# # absolute paths are ok, as are globs
# /**/postinst* text eol=lf
#
# # paths that don't start with / are treated relative to the .gitattributes folder
# relative/path/*.txt text eol=lf
* text=auto
Looks like the age old battle between \n & \r\n has returned to bite us once again ;) JK, I don't know if it's related. But that is the only thing this settings file should have affected.
Why would having the file offer a conflict if the issue is just credentials? Is it because it is a conflict with the rules within VS Code (LF / CRLF). This is very confusing, but it does make sense. I did not have this file.
Is the solution to make VS Code sensitive to this file for it's GIT Implementation?
May not be related at all, really. One this is pretty clear, when VSCode sends credentials manually via a prompt (in Windows only?), it simply doesn't work. So the easiest way to fix it is to eliminate the prompt, and that is what the command above seems to do. I did see some strange formatting in the git settings file too, but it may be unrelated. This is a file that seems to get touched when you open github desktop though.
git config --global --e
Opens the following file for me..(noticed multiple credential headings)
[user]
name = djabr..
email = <redacted>
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
[credential]
[credential]
[credential]
helper = wincred
Hi
For those who still have this problem, this worked for me
https://social.msdn.microsoft.com/Forums/vstudio/en-US/eb6853f3-b710-4be5-8b82-d55fa568e2b9/problem-with-git-on-vs-code?forum=vsarch
Regards
Hi~I have this problems as well. I'm using Coding instead of GitHub. Is it because of https protocol? How can I make the same credentials work in vs code?
Step 1 in your project folder run start-ssh-agent
Step 2 add your id_rsa or whatever name of your private RSA key password
Step 3 in the same directory open the cmd or power shell and run code
this "git config --global credential.helper wincred" might work on windows, but I'm using a mac and Microsoft forces anyone on their repositories to activate 2 factor authentication.
I cannot login from VSCode to my GitHub in order to sync with origin.
Does anyone have a workaround for a Mac?
Since I don't want to Hijack this thread for Mac, I opened a separate issue for Mac OS:
https://github.com/Microsoft/vscode/issues/46964
FYI found a workaround that seems to work on all OS systems, Mac and Windows:
Visit your github developer settings and generate a personal access token.
That token can be used as your password with your user name to login from VSCode and it seems to work normally from that point on without any special configuration.
It still doesn't work for me, I managed to login via the terminal, but using your username + password = token didn't workout very well with 2FA enabled
I noticed that even though there is a pop-up GUI window that takes the Git username and password, there is another Visual Code pop-up, under the top main menu bar in Visual Code, that asks for the Git username and password. After you enter your credentials there too, it works.
in case if you set up 2 stage auth you can use this https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
I came across to this problem too just now after enabling 2FA on my account. I've regenerated the access token for VSC, and used it as the password. I was prompted twice but it worked. (OS: Windows 10)
FYI found a workaround that seems to work on all OS systems, Mac and Windows:
Visit your github developer settings and generate a personal access token.That token can be used as your password with your user name to login from VSCode and it seems to work normally from that point on without any special configuration.
Work for me too, great job !
Code now supports automatic GitHub authentication, when using HTTPS repositories, so there's no need to support GH Desktop. This is already working in Insiders and will come out soon in the next stable.
Most helpful comment
FYI found a workaround that seems to work on all OS systems, Mac and Windows:
Visit your github developer settings and generate a personal access token.
That token can be used as your password with your user name to login from VSCode and it seems to work normally from that point on without any special configuration.