Git Config
Configure Git on Mac. The Mac Git config file. The Git config global command. Mac Git configuration for your username, email, and GitHub credentials.
Before you get started
You'll need a terminal application to configure Git. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Make sure to Check If Git Is Installed before you start.
If you've already downloaded and installed Git with either Xcode Command Line Tools or Homebrew, you should create an account on GitHub before you configure Git. Note: It is important to use the same email address for GitHub and your Git configuration.
Check for the Git config file
Check if the Git config file exists by listing the current settings with the git config -l --global
command.
$ git config -l --global
fatal: unable to read config file '/Users/.../.gitconfig': No such file or directory
If you haven't set up Git previously, you'll see "fatal: unable to read config file." You can check for the file in your user directory.
$ cat ~/.gitconfig
cat: /Users/.../.gitconfig: No such file or directory
Here's how to set your name and email address in the Git config file.
Git config name and email address
Set your name and email address. Use your real name and the same email address as your GitHub account. Careful! Don't just copy and paste the code you see here, use your own name and email.
$ git config --global user.name "Your Real Name"
$ git config --global user.email [email protected]
Check your Git configuration:
$ git config -l --global
user.name=Your Real Name
[email protected]
Set GitHub credentials
If you do nothing to configure Git credentials, you must enter a username and password every time you connect to GitHub from the command line. Entering credentials frequently adds friction and annoyance to your workflow.
To avoid entering a username and password every time you connect to GitHub from the command line, you have three options.
- Use the Git Credential Manager (easiest).
- Download and use the GitHub CLI.
- Set up a GitHub SSH key (complicated).
I recommend using the Git Credential Manager and I'll show you what to do in Git Credential Manager.
For additional information, see Caching your GitHub credentials in Git.
What's next
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.