Article From:https://www.cnblogs.com/personball/p/9125202.html

This article describes how to configure VSTS (Visual Studio Team service, actually the TFS of the Microsoft SaaS version), to access its Git code library through Personal Access Token.

problem

When you use git, you need to input passwords every time you pull and push, which is a nuisance.
When we use GitHub to manage code, GitHub provides several mechanisms to authenticate the client.

github_01

githubThe help document is perfect, and it is not expanded here, specifically see the small word link below the screenshot of generating SSH keys or generate a GPG key and add it to your.

If your project is an open source project, do you have any problems with GitHub? If you need a private library that is not public?
We generally choose Microsoft’s VSTS, so how does VSTS configure similar mechanisms to avoid entering passwords every time?

As shown in the configuration page of Personal Access Token, clickAdd

vsts_02

Fill in the description, select the validity period and which account to apply, select scopes, pull the page to the end, clickCreate Token

vsts_03

Here we must pay attention to the code and the red circle.It must be copied and saved. This token will only be displayed at the current time.,In the future, it is impossible to get it from VSTS again.

Find your code base (at least one MyFirstProject) in VSTS and copy the clone address. Enter the Powershell prompt

git clone https://familysrv.visualstudio.com/MyFirstProject/_git/MyFirstProject

If a new window is required to enter Microsoft account, it can be shut down directly. Next we can input account number and token in the command line.

vsts_05

As shown above, when the command line prompts to enter Password, enter the Token you just received.

At this point, it is proved that this token is indeed available.

But when we add a file and push it up, we also need to input the account password!

Notice that the GIT clone in front of this example is warned: This is an empty library.
Therefore, when the first git push is pushed, it is necessary to declare remote branches.git push orgin master:master

Where should we save this token?

Open it, pleaseControl panelUser accountManage your credentialswindowscredential

vsts_06

On the right side of the ordinary credentials, clickAdd ordinary credentials,If the input is in the chart, the token can be obtained before the password is filled.

vsts_07

Reopen Powershell, add or modify files, pull, push

vsts_08

No more prompts need to enter the account password, get it done!

If you are a non windows system, VSTS can also configure SSH keys to be authenticated, similar to the Github configuration, specifically the left menu of the second pictures of this article VSTS
SSH public keys

reference

This article describes how to set up VSTS Personal Access Token and use Windows credentials manager to store token: on this machine.
VSTS Personal access tokens with Git and Visual Studio 2017

Here is a detailed description of how non Windows systems avoid duplication of Github authentication passwords:
Is there a way to skip password typing when using https:// on GitHub?

Leave a Reply

Your email address will not be published. Required fields are marked *