There are multiple ways to install Git on mac. It comes inbuilt with Xcode or its other command-line tools. To start the Git, open terminal and enter the below command:

This should be the accepted answer. Also, if you have been using the system git that comes with Mac OS X, the sequence to do a new install of git via homebrew would instead be: brew install git && which git which (no pun intended!) should give you the output /usr/local/bin/git.

  • A fast and friendly git client for Mac and Windows. Download Fork for Mac. OS X 10.11+ $49.99, free evaluation. Download Fork for Windows.
  • If you are working on Mac OSX or Linux, a single set of instructions shows you how to setup and identity for either Git or Mercurial in these environments. Since you're using a Mac, you should see if the instructions at the given help link solve your problems. To be clear, here is the link again: Set up SSH for Git and Mercurial on Mac OSX/Linux.
Bash

The above command will display the installed version of Git.

Download Git Bash For Mac Os

Output:

If you do not have installed it already, then it will ask you to install it.

Apple provides support for Git, but it lags by several major versions. We may install a newer version of Git using one of the following methods:

Git Installer for Mac

This process is the simplest way to download the latest version of Git. Visit the official page of git downloads. Choose the download option for Mac OS X.

The installer file will download to your system. Follow the prompts, choose the required installer option. After the installation process completed, verify the installation was successful by running the below command on the terminal:

The above command will display the installed version of Git. Consider the below output.

Output:

Now, we have successfully installed the latest version on our mac OS. It's time to configure the version control system for the first use.

To register a username, run the below command:

To register an email address for the given author, run the below command:

To go in-depth with the git config command, visit Here.

Installation via MacPorts

Sometimes MacPorts also referred to DarwinPorts. It makes the straightforward installation of software on the Mac OS and Darwin operating systems. If we have installed MacPorts for managing packages on OS X, follow the below steps to install Git.

Step1: Update MacPorts

To update MacPorts, run the below command:

Step2: Search for the latest Ports

To search for the most recent available Git ports and variants, run the below command:

The above command will search for the latest available port and options and will install it.

Step3: Install Git

To install Git, run the below command:

We can also install some extra tools with Git. These tools may assist Git in different manners. To Install Git with bash-completion, svn, and the docs, run the below command:

Now, we have successfully installed Git with the help of MacPorts on our system.

Step4: Configure Git

The next step for the first use is git configuration.

We will configure the Git username and email address as same as given above.

To register a username, run the below command:

To register an email address for the given author, run the below command:

Install Git via Homebrew

Homebrew is used to make the software installation straight forward. If we have installed Homebrew for managing packages on OS X, follow the below steps to go with Git:

Step1: install Git

Open the terminal and run the below command to install Git using Homebrew:

The above command will install the Git on our machine. The next step is to verify the installation.

Step2: Verify the installation

It is essential to ensure that whether the installation process has been succeeded or not.

To verify whether the installation has been successful or not, run the below command:

The above command will display the version that has been installed on your system. Consider the below output:

Step3: Configure Git

We will configure the Git username and email address same as given above.

To register a username, run the below command:

To register an email address for the given author, run the below command:


Installing and configuring Git on macOS can seem difficult if you’ve never used a command line before, but there are only a few things to learn to get started. This guide will take you through the steps to install and configure Git and connect it to remote repositories to clone, push, and pull.

Installing Git

Download the latest Git installer package, double click on the installer to start the installation wizard. You’ll be prompted for your system password in order for the installer to complete.

After you have successfully installed Git on Mac, you’ll need to provide secure communication with your Git repositories by creating and installing SSH keys.

Creating SSH keys on Mac

To communicate with the remote Git repository in your Beanstalk account from your Mac, you will need to generate an SSH key pair for that computer. This process requires only a few steps, and all of the tools necessary are included on your Mac.

Launching Terminal

Terminal is an application that comes with macOS and provides you with an interface to run text commands, switch through folders, and manage files. You can usually find it in your Applications Utilities folder.

Generating a key pair

Type these commands in your Terminal window and press Return. First make sure you are in your home directory:

and then generate the keypair with:

It will ask for location, just accept the default location (~/.ssh/id_rsa.pub) by pressing Return. When it asks for a pass phrase, make sure to set a strong pass phrase for the key. We’ve included some additional information about SSH keys and how to manage strong pass phrases in our Tips for using SSH Keys guide.

Now that the keys are generated, copy it to your clipboard for the next step:

Your public key is now on your clipboard and you can easily add it to a version control hosting account like Beanstalk. When you paste it, your SSH public key should look something like this:

Git Download For Mac

In your Beanstalk account, the added SSH key will look like this:

Checking your connection

Before trying to access your Git remote repository, check if the connection to your remote hosted Git repository works. Enter the following command in the Terminal, replacing “accountname” with your account name:

In this case, this is the URL to access Git on your Beanstalk account. If you are using another version control hosting service, the URL would be provided by them.

You’ll most likely encounter a message that looks like this:

You can type yes and press Enter, which will add your account’s hostname accountname.beanstalkapp.com to a known_hosts file. This step won’t need to be repeated unless your public key or your account names changes. Also, this must be done from the Terminal before using any GUI clients.

If you were authenticated correctly, you will see a message similar to this one:

Git Bash Download Windows 10

You can now continue to configure your local Git profile.

Setting up your Git Profile

After you have authenticated correctly by installing Git and setting up SSH keys, before you start using your Git repositories, you should setup your Git profile by typing following after you run Git bash in command line:

In case you are using Beanstalk for version control, it would be best if your first name, last name and email address match to the ones you use in your account to avoid any conflicts.

Summary

Git

In order to be able to use your repository you need to:

  • Install Git
  • Generate SSH keys with ssh-keygen
  • Check if the connection to the Git repository is working
  • Set up your Git profile

While getting started with Git, the most common mistakes include mismatched private and public SSH keys or the Beanstalk user not having permission to access the repository. Make sure to check these after you have finished setting up Git. If you run into issues, just contact us using one of the links below.

Git On Mac

Now what?

Now that you have Git properly installed and configured, you can use a client of your choice. Whether you choose a terminal or a GUI, it is a good idea to learn the basic concepts and commands for versioning your files before. Here’s some recommended reading to get you started:

Git Bash Download Mac

  • Git Immersion Tutorial – an excellent step-by-step tutorial to using Git
  • Pro Git E-book and Printed Edition
  • The Git Parable – understand the concepts behind Git with a simple story by Tom Preston-Werner