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

3

7

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.

Scutch answered 16/10, 2017 at 7:41 Comment(0)
R
6

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.

Refutative answered 16/10, 2017 at 8:56 Comment(8)
Hey Andy, Actually I dont want to store my credential in git config ... I want to pass username and password in git-tf just like the below git command . I am cloning repo while passing username and password for :- git clone --mirror https://${username}:${password}@github.com/${username}/$Projectname.git. Could you please give me some suggestion how can I pass -username and password with server name in TFS url using git-tf ?Scutch
Yes and also let me know Is this good to pass username and password in command like that while cloning repo because I have to set for github and tfs both . git clone --mirror https://${username}:${password}@github.com/${username}/$Proj‌​ectname.git .Or Do you have any suggestion for that because I am writing automate script for cloning repo to localScutch
@PriyaRani For egit-tf there isn't a way to pass the credential in URL, you have to restore the username and password to eCredential Managerer or in the git configuration file as mentioned above. However you can try use git clone as you mentioned if you enable the SSH ,type the credential in the URL. Otherwise you have to store the credential first. That means you need to expose the credential, it's at risky. You can reference this thread:#10054818 for this.Refutative
-I have TFS (on-premesies ) having my server name:8080 and I m able to clone repo to my system but I am trying to clone tfs repo to another system. Below is my code :- git config --global git-tf.server:8080.username your_username git config --global git-tf.server:8080.password your_password git-tf clone server:8080/tfs/DefaultCollection $/SampleProject C:\GitTemp but getting "git-tf : git-tf: Unknown host server" . Can you give me idea how can I clone tfs(on-premises) repo to another system.?Scutch
@PriyaRani Make sure you enter the full server url, and installed the Git-TF in another system. BTW, I note that you have posted a new thread to track the new issue. So, if the answer above resolved your original issue, then you can Accept it as an Answer, This can be beneficial to other community members reading this thread.Refutative
Yes I got solution. It was networking issue. I already had git-tf installed on another system. Thank you so much for help :)Scutch
git config --global git-tf.server:8080/tfs/DefaultCollection.username Username git config --global git-tf.server:8080/tfs/DefaultCollection.password Password git-tf clone server:8080/tfs/DefaultCollection $/SampleProject D:\Repo I tried these commands in cmd it is asking eveytime username and password . I tired above command in powershell too , it showed only connecting to tfs but nothing worked no error even.Scutch
Thank you. Your commands worked for my cloning using the toolGamboge
E
3

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.

Exacting answered 27/2, 2019 at 8:56 Comment(0)
P
1

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

Pentarchy answered 24/5, 2019 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.