How to install Git on Mac
By: Lukasz Muzyka, On:
Very soon after we start writing code, we will come to the point where we would like to "go back in time" and rewrite some of that code. But the question is: how do we manage the history of our code, as it changes? Also, we may want to collaborate with some people and share the code in the future. How can we manage our code then? The answer is simple: we use something called a source code management system. Probably the most popular one is called Git. If you don't know what source code control is, just think about it as a "quick save" from a video game. You're sneaking up on some enemy,and you're afraid that things could get rough so you want to save the game state before you make the move. Git works in a similar way, but it allows you to do much much more. But for now, we will only use a couple of the very basic features.
Step 1: Download and Install Git
First things first, we need to download and install Git on our machine. If you're on Linux or Windows you can go here: http://git-scm.com/book/en/Getting-Started-Installing-Git
If you're on Mac you can use a nice installer. Download and run it.
If you're on Mavericks you may see the following warning:
This is because of some new security "improvements". Click on the installer file with the right button and select open with "Installer"
That's it. Git is running on your machine. We can now navigate to our project and start tracking the code.
Step 2: Track Code
In the Terminal, navigate to your project and run:
$ git init
Initialized empty Git repository in /Users/Lukasz/Documents/Projects/demo/.git/
Now we will add all the code that is already inside of the folder:
$ git add .
And perform the save:
$ git commit -m "Initial commit"
Inside the quotes we have to leave a message. Later, when we browse the commits we will see those messages and be able to quickly find the commit we want to check out, so remember to be descriptive when you write your commit messages.
You can login to comment