Git - Temporarily cache my username and password in memory

By xngo on May 18, 2020

Sometimes I need to access my Git repositories for a short period of times from my server. Everytime that I pull my repository, it asks for my username and password. It becomes really annoying.

Solution

Git provides a neat little helper called git-credential-cache. It temporarily stores passwords in memory.

git config credential.helper cache --timeout 3600
git pull origin master
Username: <type your username>
Password: <type your password>

By default, --timeout is set to expire in 900 seconds, which is 15 minutes. I set mine to time out in 1 hour.

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.