This article describes how to configure VSTS (Visual Studio Team Service, in fact, Microsoft SaaS version of TFS) to access the GIT code library under Personal access token.
Problem
When using Git, it's a nuisance to have to enter a password each time you pull and push.
When we use GitHub to host the code, GitHub provides several mechanisms to authenticate the client, the configuration page such as:
GitHub's help documentation is perfect and is not expanded here, specifically see the small small link below generating SSH keys or generate a GPG key and add it to the your account.
If your project is an open source project, there is no problem on GitHub, what if you need a private library that is not public?
We typically choose Microsoft's VSTS, so how does VSTS configure a similar mechanism to avoid having to enter a password every time?
Get Personal Access Token
, Personal Access Token's configuration page, clickAdd
Fill in the description, select a valid period and which account to apply, select scopes, page pull to the end, clickCreate Token
It must be noted here, the figure of the code and red circled part, must be copied down to save, this token will only be displayed once , and later can not be retrieved from VSTS.
Personal Access Token in native management
Well, we got the personal Access token, and then we verify that we can use the token properly.
Open a directory locally, press Shift
and hold the key, right-click in the space, select 在此处打开Powershell窗口
:
Find your codebase (at least a myfirstproject) in VSTS and copy the clone address. In the PowerShell prompt, enter
git clone https://familysrv.visualstudio.com/MyFirstProject/_git/MyFirstProject
If a new window is required to enter a Microsoft account, you can close it and we can then enter the account and token on the command line.
For example, when the command line prompts for password, enter the token you just received.
At this point, it proves that the token is indeed available.
However, when we add files, push up, you will also be prompted to enter the account password!?
Note that there is a warning when git clone is in front of this example: This is an empty library.
So, when the first git push pushes, you need to declare the remote branch, for examplegit push orgin master:master
Where should we save this token?
Please open 控制面板
,,, 用户账户
管理你的凭据
windows凭据
:
On the right side of the normal credentials, click 添加普通凭据
, enter, password to fill in before the token can be.
Reopen PowerShell, add or modify files, pull, push
No more prompts need to enter the account password, done!
If you are a non-Windows system, VSTS can also configure the way SSH keys to authenticate, and GitHub configuration is similar, see the second picture in this article VSTS left menu
SSH public keys
Reference
This article describes how to set up VSTS's personal Access token and use Windows credentials Manager to store this token natively:
VSTS Personal access tokens with Git and Visual Studio 2017
Here is a detailed explanation of how non-Windows systems can avoid re-entering the GitHub authentication password:
Is there a-to-skip password typing when using https://on GitHub?
[2018-05-27] Configuring VSTS authentication using Personal access Token