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.
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
.
brew install gh
in your terminalgh auth login
in your terminalGitHub.com
and hit the enter keyHTTPS
and hit the enter keyGitHub.com
and hit the enter keyY
to authenticating with your GitHub credentials and hit the enter keyLogin with a web browser
and hit the enter keycontinue
.Authorize github
buttonNow you won’t have to use your GitHub login each time you use the git
program.
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!