Nithin Bekal Posts About

Set up Git on Windows

31 Aug 2010

In this post, I will describe the steps to install git on a windows machine, create a local repository, and then push that repo to your github account. This is a beginner level tutorial for those using windows, but except for the part about installation, it is common for all OSes.

Installation and set up

Download and install msysgit from Msysgit comes with a GUI tool and a command line version.

Next you have to set up your name and email into git configuration. For this, open git bash and use the following commands:

$ git config --global "Nithin Bekal"
$ git config --global

Creating the first repo

Now that the installation and configuration steps are done, let’s create our first repository. Create a folder called my_project and add some files to it. I created a rails project using rails my_poject since that automatically generates many files and folders.

Go to the project directory

$ cd my_project

Initialize a git repository for the project:

$ git init

Add all the files in the project to the repository:

$ git add .

Make the first commit.

git commit -m "First commit."

This commits all the changes (all the files in this case, because we have a new repo here) to the repository along with the message “First commit”.

Pushing the repo to Github

The next step is to push this repository to Github. First of all, you need to sign up for an account (if you don’t already have one) on Github. Once you’ve created the account, create a new repository called my_project.

Before you can start pushing to Github, you need to create an ssh key for your computer and copy the public key to your Github account.

Create SSH key:

$ cd ~
$ mkdir .ssh
$ cd .ssh
$ ssh-keygen -t rsa -C ""

Now in giithub, go to Account settings > Add SSH keys > Add another public key and copy the contents of the file there. You will have to create an ssh key and add it to github for each computer from which you want to push repos to github.

To push the local repository to github:

$ git remote add origin
$git push origin master

Now if you open the page for the repository on your browser, you can see the files of your project visible there. If you have a readme file in your project folder, the contents of that file will also be displayed. That’s it! Now you have the git repository available on Github.

Nithin Bekal
Hi, I’m Nithin! This is my blog about programming. Ruby is my programming language of choice and the topic of most of my articles here, but I occasionally also write about Elixir, and sometimes about the books I read. I'm @nithinbekal on Twitter.