Saving your Git credentials

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

If Git prompts you for a username and password every time you try to interact with GitHub or a GitLab server,  you’re probably using the HTTPS clone URL for your repository.

Using an HTTPS remote URL has some advantages: it’s easier to set up than SSH, and usually works through strict firewalls and proxies (like here in DkIT). However, it also prompts you to enter your credentials every time you pull or push a repository!

You can configure Git to store your password for you. If you’d like to set that up, read all about setting up password caching below.

At the command line execute the following


or even

then provide user-name and password and those details will be remembered later. The credentials are stored in a file on the disk, with the disk permissions of “just user readable/writable” but still in plaintext.

if you want to change password later

will fail, and because it failed, it removes the offending user+password from the .git-credentials file, so now we have to run

again and provide the new password. it will now work like before. See this link for more info.

If using the Git version control system built into Eclipse products (EGit) then open Window > Show View > Other and choose Git >Git Repositories

Choose to “Clone a Git repository”

and fill in the following dialog, remembering to use check “Store in Secure Store”

Your Eclipse product should now remember your Git credentials for all future connections. Unlike previously, the secure storage saves data in an encrypted form. You can change your  password later via the Change Password… button on the Secure Storage preference page. See here for more information.

Note: Computer Services ares currently building and testing a GitLab server for use in the department next year. We will post more Git-related tutorials closer to the launch date!