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 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.
-
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>
-
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
-
Tell Git to use
osxkeychain helper
using the globalcredential.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.
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.
-
In Terminal, enter the following:
git config --global credential.helper cache # Set git to use the credential memory cache
-
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.
-
On the command line, enter the following:
git config --global credential.helper cache # Set git to use the credential memory cache
-
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)