Git and Github

Git is a distributed version control system and it differs from a centralized version control system like SVN in quite a few respects.

SVN involves a central repository. Each client then checks out a copy of this repository to make a local copy called the ‘Working directory’. Each client makes changes to his own working directory. The changes are committed to the Central repository when the client checks in i.e.commits the code.The central repository maintains the older versions of the code as well. Hence the client can rollback his working directory to a previous version of code from the central repository.

Git (–distributed is the new centralized) also includes a central repository. But in addition to the central repository, each client has his own repository on his local machine. Essentially, the working directory in this case acts as a repository in itself. Commits, rollbacks etc are to be done first at the working directory level and then pushed to the remote branch in the central repository. The client here can rollback to a previous version of code from his local repository or from the central repository.

For more details on the differences between Git and SVN, here is a good link

When you are moving away from SVN and towards Git, things can be confusing. I published a couple of projects on Github and that is how I got my first taste of Git.

This blog simply aims at giving you the basic Git commands that you need to know in order to work with Git and publish your projects to Github. The commands and responses below are all from MAC OS X 10.8.5 Terminal app.

To demo this, I am going to create a Test iOS project and publish it to Github.

1. Create an account at

2. Create your project on your MAC that you wish to publish to github. In my case, I am creating a Test iOS application project. Xcode provides you a capability to create a git repository as you create the project, but I will create it using a terminal command.

3. Check if you have git on your MAC. The latest versions of MAC OS X come with built in Git. You can check for this from the Terminal using the command

$ git –version

If you do not have git installed on your desktop, download and install it from

Once git is installed, navigate to your project folder path in the Terminal and use the below command to create your local git repository:

$ git init

4. You can see that the above command adds a .git hidden folder in your project folder. To see the .git folder, navigate to your project folder in Finder, click on the ‘Go’ option on the top menu and select ‘Go to Folder’. Type in ‘.git’ and click Go. This will show you the hidden .git folder and the contents under it.

.git folder

5. On github, login with your account and go to Repositories tab. Click on ‘New’ to create a new repository. Provide the repository name. In this case, I am going to name it as ‘Test’. Provide a description (although it is optional, its good to provide one). Select the option ‘Private’ or ‘Public’ to indicate who can see the repository. ‘Private’ option will need you to have a paid account with github.

At this point you can add the README file and license by selecting the checkbox ‘Initialize this repository with a README’ and selecting appropriate options in the dropdowns below. You can add these files later as well.

Creating new repository on github

Click on Create Repository. At this point, this is an empty repository on github.

Github Test repository

You will now need to add your project to this repository.

6. In order to add your project to the github repository, you will first need to add the files and folders of the project and commit them locally. In order to do this, type the following commands in the terminal:

In order to selectively add the files to commit, type the following command:

git add <files or folder name>

Alternately, in order to add all the files in the current folder and its subfolders, type the command as

git add .

7. Once the files to commit have been added, you need to do a local commit first using the command

git commit -m “message”

“message” should be any commit message that you wish to provide.

add and commit files

8. Configure your git username, email address and password as below

git config –global “your name to be visible when you commit”

git config –global “your email associated with github”

git config –global user.password “your github password”

9. You will then need to add your github ‘Test’ repository as your remote origin using the command:

git remote add origin <git repository url>

10. Your remote repository is called has the origin branch by default. To push your local repository a.k.a. master to the remote github repository, use the command:

git push origin master

push to origin

If you now check your repository on github, you will see your project files added in it.

Github Test repository

11. To update your local copy with the changes from the remote repository, use the command

git pull <git repo url> <branch name>

If you do not wish to work with the command line tools, there are GUI clients available for git. Take a look at

These are the basic steps to using git and publishing to github. There is a lot more to git than this. This should hopefully help you get started. Do leave your comments if you found this useful.