Cloning Git Repo using TFS Personal Access Token

后端 未结 4 1219
醉话见心
醉话见心 2021-02-02 17:23

I am trying to programmatically clone a git repository. My ASP.NET MVC application is creating and starting a process. The code to handle the processes works correctly however t

4条回答
  •  无人共我
    2021-02-02 17:55

    You can use the CredentialManager by programmatically adding the token to the machine, the same way CredentialManager would do it.
    On Windows I use the cmdkey tools as follow:

    cmdkey /generic:"git:https://yourdomain.visualstudio.com" /user:"Personal Access Token" /pass:"yourtokenhere"
    

    On MacOS add an entry in the keychain:

    security add-generic-password -a "Personal Access Token" -D "Credential" -s "gcm4ml:git:https://yourdomain.visualstudio.com" -w "yourtokenhere" -A
    

    Note: Avoid using -A which allows any application to access it.

    As long as the CredentialManager is installed on Git, it should work.

提交回复
热议问题