By far the most secure way to do this is to simply not store a password and to instead use single sign-on via Kerberos or NTLM:
If you're on Windows and logged into a domain that has a trust relationship with your TFS server, then you should not need to specify a username and password.
If you're on Windows and have a "shadow account" setup, then you should not need to specify a username and password. This occurs when you don't have a domain trust relationship with the TFS server but you are logged in to your local machine with the same username and password as the account on your TFS server.
If you're on a Unix platform, you can get single sign-on using Kerberos. This is most likely the scenario when you have a ticket from your Active Directory server itself, eg kinit activedirectory.domain.name
.
Similarly, if you're on Unix and have a Kerberos ticket to a KDC that has a trust relationship with the TFS server (almost certainly the Active Directory server itself) then you should not need to specify a username and password. git-tf
will use your logged in credentials to authenticate.
If none of these applies, then you can store the username and password in the git configuration for your repository:
git config git-tf.server.username your-username
git config 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.