4

I am pushing from my windows box to a repository cloned from an http (not ssh) address. Each push, I have to enter my u/p. I want to automate this process. I have tried the following:

$ git config credential.helper cache
$ git config credential.helper 'cache timeout=360000'

But those settings had no effect and I still have to enter the u/p each time. Is there any way to automate it?

Jonah
  • 15,806
  • 22
  • 87
  • 161

3 Answers3

7

Use _netrc file to store your username/password for remote machine, described here

Community
  • 1
  • 1
tomgi
  • 1,422
  • 11
  • 20
  • On my work machine the _netrc method would not work when placed into my profile C:\Users\Name.Domain. Moved to C:\Users\Name and it works. – SurfRat Jun 12 '13 at 06:30
2

Newer versions of Git support a more streamlined credentials API. Depending on implementation of the credentials helper, this is typically more convenient and secure than using .netrc.

A popular windows credentials helper is git-credential-winstore.exe. Simply download to the git/bin path and execute. Github supplies a similar helper.

Additional detail here (but not specific to Windows):

Community
  • 1
  • 1
kaliatech
  • 17,579
  • 5
  • 72
  • 84
0

Note: the syntax would be:

git config credential.helper 'cache --timeout=3600'

Otherwise, the default cache time is 15 minutes.

Actually, Git 2.39 (Q4 2022) updates the credential-cache documentation to provide a more realistic example.

See commit f13c3f2 (09 Nov 2022) by M Hickford (hickford).
(Merged by Taylor Blau -- ttaylorr -- in commit 3f98d7a, 18 Nov 2022)

Documentation: increase example cache timeout to 1 hour

Signed-off-by: M Hickford
Signed-off-by: Taylor Blau

Previously, the example decreased the cache timeout compared to the default, making it less user friendly.

Instead, nudge users to make cache more usable.
Many users choose store over cache.
See this thread

The default timeout remains 15 minutes.
A stronger nudge would be to increase that.

git credential-cache now includes in its man page:

variable (this example increases the cache time to 1 hour):

 $ git config credential.helper 'cache --timeout=3600'
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250