how to pass username and password while cloning TFS to git in window powershell

15.9k views Asked by At

I want to import TFS repo to git and clone into my local machine and I am using git-tf. Below my code:- git-tf clone http://server:8080/tfs/DefaultCollection $/SampleProject D:\TFSRepoName I want to pass username and password in url , so it automatic clone repo without asking for username and password.

3

There are 3 answers

8
Andy Li-MSFT On BEST ANSWER

If you don't want to be prompted for credentials every time you run git-tf, you can store your credentials in your GIT configuration for your repository:

$ git config --global git-tf.server.username your-username
$ git config --global git-tf.server.password your-password

Note that your password will be stored in the git configuration file in plain text. Be sure to set the ACLs or file permissions as appropriate to discourage people from reading your password out of your configuration file. Or you can store just the username and you will need to type only your password each time.

Reference : Accessing TFS with git-tf


You can also try to install and Use the Git Credential Manager,

When you connect to a Git repository from your Git client for the first time, the credential manager will prompt for your credentials. Once authenticated, the credential manager will create and cache a personal access token for future connections to the repo. Git commands that connect to this account will not prompt for user credentials until the token expires or is revoked through VSTS/TFS.

0
Shubham Jain On

One way to pass the credential is -

git pull http://username:password@url

Here "url" will be the url you use to clone the repository on tfs. But this way is not recommended. Instead you should go for credential manager.

0
Kyle Burkett On

I had to use the default windows credential manager (windows 10 comes with this feature).

  • Control Panel\User Accounts\Credential Manager
  • Click windows credentials
  • Add generic credential
  • git:(tfs url, no trailing slash) ... example: git:http://tfs
  • username .. example: domain\username
  • password
  • save

Next time you use git for this url your saved credentials will be used