macOS Setup Instuctions

Basic Setup

On macOS, Git and GCC come with the Xcode command line tools package. This package must be installed separately from Xcode itself. To see if you already have it installed, open up the Terminal application. When you open up Terminal, you will be presented with a black window with some text that will probably have your username in it and possibly the name of your computer in a format like this before a cursor:

Computer-Name:~ Username$

The appearance of your terminal could be different, but you should still be able to run commands using this prompt.

When describing commands in the following steps, I will prefix them with a $ character to indicate that this is a command line instruction. You do not need to type in the first $ character.

First try running Git by typing the following command and hit enter:

$ git

If Git is already installed you will see a usage message. If not, a window will pop up asking if you want to install the Xcode command line tools. Install them now if this happens.

Note: If you are running macOS Big Sur you might get an error that looks like xcrun: error:.... In that case you can run the following command to update your command line tools and fix that issue:

$ xcode-select --install

After installing the command line tools, you may get the following message:

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

If so, run this command:

$ sudo xcodebuild -license

You will be prompted for a password, enter the password for your computer. You can scroll through the license by pressing the spacebar, and press q to stop reading the license. You will then need to type agree and press the enter key. Once you have completed this, try running git again.

Install gh

We will need one more tool called gh to make using git with GitHub a little bit easier. Note that you must have complete the previous steps before you can install gh.

  1. Go to the website for Homebrew
  2. Open a terminal
  3. Copy and paste the command on the Homebrew homepage to install homebrew
  4. Wait for the install to complete
  5. Run: brew install gh in your terminal
  6. Wait for the install to complete
  7. Run: gh auth login in your terminal
  8. Use the arrow keys to select GitHub.com and hit the enter key
  9. Use the arrow keys to select HTTPS and hit the enter key
  10. Use the arrow keys to select GitHub.com and hit the enter key
  11. Say Y to authenticating with your GitHub credentials and hit the enter key
  12. Use the arrow keys to select Login with a web browser and hit the enter key
  13. Copy the code that appears in the terminal window
  14. Press the enter key
  15. Use the browser window the opens to login to GitHub
  16. After loging in, paste the code you copied from the terminal window into the browser and click continue.
  17. Click the Authorize github button

Now you won’t have to use your GitHub login each time you use the git program.

Configuring Git (First Time Only)

Open a macOS Terminal and run the following commands replacing my name and email with your name and email address.

$ git config --global user.name "Drew Guarnera"
$ git config --global user.email dguarnera@wooster.edu
$ git config --global core.editor nano

That’s it, git is ready to go!