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.

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.

Now in giithub, go to Account settings > Add SSH keys > Add another public key and copy the contents of the id_rsa.pub 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.

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.

Hi, I’m Nithin Bekal.
I work at Shopify in Ottawa, Canada.
Previously, co-founder of
CrowdStudio.in and
WowMakers.
Ruby is my preferred programming language,
and the topic of most of my articles here,
but I'm also a big fan of Elixir.
Tweet to me at @nithinbekal.