致命:cmd 中的 git 身份验证失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44177091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:46:45  来源:igfitidea点击:

fatal: Authentication failed in git in cmd

gitazure-devops

提问by macro_controller

I'm trying to push a branch (git push <remote> master) to my remote repository. When I'm doing it from cmd, I'm prompted with my user name and password:

我正在尝试将一个分支 ( git push <remote> master)推送到我的远程存储库。当我从 cmd 执行此操作时,系统会提示我输入用户名和密码:

Username for 'https://<my_domain>.visualstudio.com': <my_user_name>

Username for 'https://<my_domain>.visualstudio.com': <my_user_name>

Password for 'https://<my_user_name>@<my_domain>.visualstudio.com':

Password for 'https://<my_user_name>@<my_domain>.visualstudio.com':

and after typing it I get:

输入后我得到:

fatal: Authentication failed for https://<my_domain>.visualstudio.com/<my_repo>'

fatal: Authentication failed for https://<my_domain>.visualstudio.com/<my_repo>'

However when I do the same thing from git bash it just works, without prompting the username and password.

但是,当我从 git bash 做同样的事情时,它就可以工作,而不会提示用户名和密码。

I checked the user name and password in the repository at visual studio team serviceswhere the repository hosted, and it seems like working.

我在存储visual studio team services库托管的存储库中检查了用户名和密码,它似乎工作正常。

Checking git config user.nameand git config user.passwordfrom git bashyielded exactly the username and password that I'm typing in cmd.

检查git config user.namegit config user.passwordfromgit bash产生了我在 cmd 中输入的用户名和密码。

Does anyone know what am I doing wrong with the authentication, and how can I configure git to connect correctly from cmd?

有谁知道我在身份验证方面做错了什么,以及如何配置 git 以从 cmd 正确连接?

I looked through similar questions on the site, but didn't find anything that works.. Thanks!

我在网站上浏览了类似的问题,但没有找到任何有效的东西..谢谢!

回答by macro_controller

git config --global credential.helper managersolved the problem

git config --global credential.helper manager解决了问题

回答by Ankit

In Windows:

在 Windows 中:

  1. Goto control panel
  2. Select User Accounts
  3. Select Manage Windows Credentials under Credential Manager
  4. Choose the entry of the git repository, and Edit the user and password.
  1. 转到控制面板
  2. 选择用户帐户
  3. 在凭据管理器下选择管理 Windows 凭据
  4. 选择 git 存储库的条目,并编辑用户和密码。

Done!

完毕!