无法使用 Git Bash 向 Visual Studio Team Services 进行身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21808341/
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
Unable to authenticate with Git Bash to Visual Studio Team Services
提问by onefootswill
I am unable to run any commands against my remote repository at Visual Studio Team Services (VSTS) because authentication fails.
由于身份验证失败,我无法在 Visual Studio Team Services (VSTS) 上针对我的远程存储库运行任何命令。
I am able to do pulls, etc. through Visual Studio. But only through Visual Studio. Not through Git Bash, or any other tool like SourceTree.
我可以通过 Visual Studio 进行拉取等操作。但只能通过 Visual Studio。不是通过 Git Bash 或任何其他工具,如SourceTree。
回答by Anthony Chu
You need to enable Alternate Authentication Credentials if you want to use other Git clients outside of Visual Studio...
如果要使用 Visual Studio 之外的其他 Git 客户端,则需要启用备用身份验证凭据...
To set up alternate creds in Visual Studio Team Services (VSTS), click on your name/icon on the top right -> Security -> Alternate Authentication Credentials
要在 Visual Studio Team Services (VSTS) 中设置备用凭据,请单击右上角的姓名/图标 -> 安全性 -> 备用身份验证凭据
Edit: Add more details about this from VSTS (taken from the alternate credentials screen)...
编辑:从 VSTS 添加有关此的更多详细信息(取自备用凭据屏幕)...
ALTERNATE AUTHENTICATION CREDENTIALS
Some applications that work outside the browser (including Team Explorer Everywhere command line client and the git-tf utility) require basic authentication credentials. Other applications do not properly handle using an e-mail address for the user name during authentication.
To work with these applications, you need to enable alternate credentials, set a password, and optionally set a secondary user name not in the form of an e-mail address. Please note that alternate credentials cannot be used to sign in to the service from a web browser or outside of these applications.
备用身份验证凭据
一些在浏览器之外工作的应用程序(包括 Team Explorer Everywhere 命令行客户端和 git-tf 实用程序)需要基本的身份验证凭据。其他应用程序在身份验证期间无法正确处理使用电子邮件地址作为用户名。
要使用这些应用程序,您需要启用备用凭据、设置密码,并可选择设置非电子邮件地址形式的辅助用户名。请注意,不能使用备用凭据从 Web 浏览器或这些应用程序之外登录服务。
回答by Azadeh Khojandi
Enable alternate authentication credentials and set secondary username
Create a personal access token for your Visual Studio Team Services account and copy the token
Open Git Bash and go to the folder that you cloned your repository to and enter the following command to make sure it stores the credentials and you don't need to enter it every time:
git config credential.helper store
git pull origin [your branch]
It asks for user name and password. Enter user name and token as password
回答by Lyall
On Windows, you can easily create a Personal Access Token using the Git Credential Manager. It's what Visual Studio Team Services now seems to recommend over the Alternate authentication credentials.
在 Windows 上,您可以使用Git Credential Manager轻松创建个人访问令牌。这就是 Visual Studio Team Services 现在似乎推荐的替代身份验证凭据。
Just install that utility, and then the next time you git pull
from Git Bash, it will prompt you for your Visual Studio Team Services access credentials. It will then create a Personal Access Token in your VSTS account, and add a couple of entries to your local Windows Credentials store.
只需安装该实用程序,然后下次您git pull
使用 Git Bash 时,它就会提示您输入 Visual Studio Team Services 访问凭据。然后它将在您的 VSTS 帐户中创建一个个人访问令牌,并将几个条目添加到您的本地 Windows 凭据存储中。
Quote from the site:
来自网站的报价:
It magically works when credentials are needed. For example, when pushing to Visual Studio Team Services, it automatically opens a window and initializes an oauth2 flow to get your token.
当需要凭据时,它会神奇地工作。例如,当推送到 Visual Studio Team Services 时,它会自动打开一个窗口并初始化 oauth2 流以获取您的令牌。
回答by megamaiku
I noticed the wording (and location) of the menus changed in Visual Studio Team Services. It is now located in the drop-down menu at the top-right corner (with your initials or photo) Security → Alternate authentication credentials. Just enable and make up your username and password.
我注意到 Visual Studio Team Services 中菜单的措辞(和位置)发生了变化。它现在位于右上角的下拉菜单中(带有您的姓名首字母或照片)Security → Alternate authentication credentials。只需启用并设置您的用户名和密码即可。
回答by hawkeyecoder
When using Atlassian SourceTree you need the basic credentials setup in Visual Studio Team Services (VSTS) like in the accepted answer.
使用 Atlassian SourceTree 时,您需要像接受的答案一样在 Visual Studio Team Services (VSTS) 中设置基本凭据。
Then in SourceTree go to menu Tools→ Options→ Authenticationtab.
然后在 SourceTree 中转到菜单工具→选项→身份验证选项卡。
You need to set the non-email username that you set up as basic username credentials for the XXX.visualstudio.com host.
您需要设置您设置为 XXX.visualstudio.com 主机的基本用户名凭据的非电子邮件用户名。
You will then be prompted for the password when accessing that VSTS Git repository.
然后,在访问该 VSTS Git 存储库时,系统会提示您输入密码。
回答by Nhan
Downloading the latest version of Git and including the Git Credential Manager worked for me.
下载最新版本的 Git 并包括 Git Credential Manager 对我有用。
回答by Risky Pathak
As per 2017-06-21, the page to enable alternate authentication settings is at
the link https://*YOUR_USER_NAME*.visualstudio.com/_details/security/altcreds
.
根据 2017-06-21,启用备用身份验证设置的页面位于链接中https://*YOUR_USER_NAME*.visualstudio.com/_details/security/altcreds
。