Using Git with HTTPS

DevOps Git

Although SSH is preferred, if you want to use Git’s credential helper here’s two simple options, note you’ll probably not want to use the Credentials Helper method, because it stores the credentials in a plain-text file, albeit in your home directory, but still. Using the Credentials Helper, you won’t have to re-enter your username and password each time to commit, push or pull!

Store Credentials Temporarily in Memory

Git can cache your credentials in memory for a specified time (e.g., 15 minutes):

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

This will remember your credentials for one hour (3600 seconds). You can adjust the --timeout value as needed. You’ll still need to enter the credentials once, but you’ll not have to keep re-entering each time you need to do something with git.

Store Credentials Permanently:

If you want Git to remember your credentials permanently, you can use the Git credential store:

git config --global credential.helper store

After running this command, Git will store your username and password in a plain-text file (~/.git-credentials). The next time you push, Git will automatically use the stored credentials without prompting you.

Note: This method stores your credentials in plain text, which is not the most secure approach. You might prefer using a different method or tool like an SSH key.

Leave a Reply

Your email address will not be published. Required fields are marked *