Set up Git on Windows
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 http://msysgit.github.io/. 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:
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
Initialize a git repository for the project:
Add all the files in the project to the repository:
Make the 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:
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.
To push the local repository 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.