Setting Git and GitHub on Mac OS X

If you are running Mac OS 10.9 (Mavericks) and later you may want to check out GitHub for Mac and install different Git version then the one noted below. 

In this post I’ll walk through the several steps needed to have a running GitHub account synched to a local Git repository. If all these words sounds too intimidating to you I’ll explain it briefly in the text paragraph.

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency” – source code developers are creating is being managed by version control systems and Git is an open source (and free) example of that. “GitHub is a web-based hosting service for software development projects that use the Git revision control system.”  – essentially GitHub makes a connection between what is being managed on your computer and enable internet access to it so other people can have access to your code too.

Creating GitHub Account

Use your browser to create a free account at GitHub‘s website. It’s pretty straightforward. After you are done with that follow this guide to create your first repository on GitHub.

Installing Git on Your Mac (no XCode is needed)

Now it’s time to move to your computer and install Git. While writing these lines the latest Git version for Mac wasn’t compatible with Mac OS 10.8 so I needed to look elsewhere. I found a .dmg Git versions here and downloaded the latest version that supported Mac 10.8 – 2.0.5 from here following the guidelines that are found in this downloading website (in my case taking the latest snow-leopard version).

  • 10.6 Snow Leopard: git-*-snow-leopard
  • 10.7 Lion: git-*-snow-leopard
  • 10.8 Mountain Lion: git-*-snow-leopard
  • 10.9 Mavericks: git-*-mavericks
  • 10.10 Yosemite: git-*-mavericks

After clicking the .dmg file open your Mac Terminal window.  This is well described in this very short video.

Getting Things Ready

Now that you have your Git installed properly and you have set your Github account and created one repository in it we can get to business. But before we do that, we’ll follow some basic required steps.

First things first, let’s verify things are installed correctly by checking our Git version terminal window.

$ git --version
git version 2.0.5 

Tell Git your name so your commits will be properly labeled.

$ git config --global "YOUR NAME"

Tell Git the email address that will be associated with your Git commits. The email you specify should be the same one found in your GitHub email settings. To keep your email address hidden, see “Keeping your email address private“.

$ git config --global "YOUR EMAIL ADDRESS"

There are two ways to authenticate from GitHub to Git – SSH and HTTPS. I’ll use the latter so let’s save some time using our GitHub user and password later on by using the credential-oskeychain command.

$ git credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase> 

And finish up by typing the following:

$ git config --global credential.helper osxkeychain 

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.

Basic Work with Repository

Finally! We are ready to start working with our repository.

We first want to use the clone command to have our GitHub repository cloned to our computer. You’ll find the URL for your repository by following this guide

$ git clone
Cloning into 'OpenStackFiles'...
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (9/9), done.
Checking connectivity... done.

We’ll change directory on our computer so then we can use the status command to check the differences between our local repository and the remote GitHub repository

yaniv-zadkas-macbook:OpenStackFiles yanzadka$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

We can use the pull command to fetch whatever been updated on our GitHub repository to our computer local one.

yaniv-zadkas-macbook:OpenStackFiles yanzadka$ git pull 

Next we can use the add command to a “stage” for commit after creating a file called test.txt

yaniv-zadkas-macbook:OpenStackFiles yanzadka$ git add test.txt 

add has few more options. You can read about it here.

Now that our file is past it’s “staging” process we can commit it to our local repository

yaniv-zadkas-macbook:OpenStackFiles yanzadka$ git commit -m test.txt "committing test.txt file"

And last, in order to have it available on our GitHub repository we’ll use the push command

yaniv-zadkas-macbook:OpenStackFiles yanzadka$ git push test.txt 

We can now refresh our GitHub OpenStackFiles repository and find out that the file test.txt is available there.

I would highly recommend the first 14 minutes of this video to have a better understanding of Git and GitHub basic functionality.



One thought on “Setting Git and GitHub on Mac OS X

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s