This version of GitHub Enterprise will be discontinued on This version of GitHub Enterprise was discontinued on 2020-08-20. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Article version: Enterprise Server 2.18

Caching your GitHub credentials in Git

If you're cloning GitHub Enterprise repositories using HTTPS, you can use a credential helper to tell Git to remember your credentials.

If you clone GitHub Enterprise repositories using SSH, then you authenticate using an SSH key instead of using other credentials. For information about setting up an SSH connection, see "Generating an SSH Key."

Tips:

  • You need Git 1.7.10 or newer to use the osxkeychain credential helper.
  • If you installed Git using Homebrew, the osxkeychain helper will already be installed.
  • If you're running Mac OS X 10.7 and above and you installed Git through Apple's Xcode Command Line Tools, then osxkeychain helper is automatically included in your Git installation.

Install Git and the osxkeychain helper and tell Git to use it.

  1. Find out if Git and the osxkeychain helper are already installed:

    $ git credential-osxkeychain
    # Test for the cred helper
    > Usage: git credential-osxkeychain <get|store|erase>
  2. If the osxkeychain helper isn't installed and you're running OS X version 10.9 or above, your computer will prompt you to download it as a part of the Xcode Command Line Tools:

    $ git credential-osxkeychain
     > xcode-select: note: no developer tools were found at '/Applications/Xcode.app',
     > requesting install. Choose an option in the dialog to download the command line developer tools.

    Alternatively, you can install Git and the osxkeychain helper by using Homebrew:

    $ brew install git
  3. Tell Git to use osxkeychain helper using the global credential.helper config:

    $ git config --global credential.helper osxkeychain
    # Set git to use the osxkeychain credential helper

The next time you clone an HTTPS URL that requires authentication, Git will prompt you for your username and password. Password-based authentication for Git is deprecated, and we recommend using a personal access token (PAT) when prompted for a password instead, which is more secure. Treat your token just like a password. For more information, see "Creating a personal access token."

Once you've authenticated successfully, your credentials are stored in the macOS keychain and will be used every time you clone an HTTPS URL. You won't be required to type your credentials in to Git again unless you change your credentials.

Tip: You need Git 1.7.10 or newer to use the credential helper.

You can also install a native Git shell, such as Git for Windows. With Git for Windows, running the following in the command line will store your credentials:

$ git config --global credential.helper wincred

Tip: You need Git 1.7.10 or newer to use the credential helper.

Turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.

  1. In Terminal, enter the following:
    $ git config --global credential.helper cache
    # Set git to use the credential memory cache
  2. To change the default password cache timeout, enter the following:
    $ git config --global credential.helper 'cache --timeout=3600'
    # Set the cache to timeout after 1 hour (setting is in seconds)

Further reading

Ask a human

Can't find what you're looking for?

Contact us