To automate authenticating either use:
- SSH keys as others have already pointed out, or
- the built-in credential helper.
Obviously, do not store your password in a text file unless the repo is not important.
TortoiseGit >1.8.1 installs the helper git-credential-winstore which provides the local API to access and store your login info in the existing, local Windows Credential Store.
You can see the stored credentials by going to Control Panel → User Accounts → Credential Manager and choosing "Windows Credentials". The entries starting "git:" are from git-credential-winstore.
You can set up wincred per repository by:
(GUI)
- Navigate to the repository in File Explorer.
- Context-click → TortoiseGit → Settings → Git → Credential
- Credential helper: wincred - this repository only
- The next time you authenticate with the repo, the credentials will be stored.
(CLI, POSH)
cmdkey /add:git:https://USERNAME@github.com /user:USERNAME /pass:PASSWORD
@"
[credential]
helper = wincred
"@ | Out-File -FilePath $repoRoot\.git\config -Append
You can list all credentials stored for repos with cmdkey /list:git:*
Once stored, passwords are not displayed by cmdkey (http://ss64.com/nt/cmdkey.html)
To list all credentials with passwords you need to use the Windows API. For powershell, there's CredMan:
. .\CredMan.ps1
.\CredMan.ps1 -ShoCred