If you're cloning GitHub repositories using HTTPS, you can use a credential helper to tell Git to remember your GitHub username and password every time it talks to GitHub.

If you clone GitHub repositories using SSH, then you authenticate using SSH keys instead of a username and password. For help setting up an SSH connection, see Generating SSH Keys.

Tips:

  • You need Git 1.7.10 or newer to use the credential helper.
  • If you installed Git using Homebrew, the osxkeychain helper may already be installed.

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

  1. Find out if the osxkeychain credential helper is already installed by trying to run it:

    git credential-osxkeychain
    # Test for the cred helper
    # Usage: git credential-osxkeychain <get|store|erase>
    
  2. If the osxkeychain helper isn't installed, download it with curl:

    git credential-osxkeychain
    # Test for the cred helper
    # git: 'credential-osxkeychain' is not a git command. See 'git --help'.
    curl -s -O \
    https://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
    # Download the helper
    chmod u+x git-credential-osxkeychain
    # Fix the permissions on the file so it can be run
    
  3. Install the helper into the same directory where Git itself is installed:

    sudo mv git-credential-osxkeychain \
    "$(dirname $(which git))/git-credential-osxkeychain"
    # Move the helper to the path where git is installed
    # Password: [enter your password]
    
  4. Tell Git to use osxkeychain 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 a password, you'll be prompted for your username and password, and to grant access to the OSX keychain. After you've done this, the username and password are stored in your keychain and you won't be required to type them in to Git again.

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

If you install GitHub for Windows, the credential helper is included. The app also provides a Git shell so you won't ever need to install and configure Git manually.

If you prefer working with the command line, you can also install a native Git shell, such as msysgit. With msysgit, 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)
    

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. On the command line, 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)