Getting started with Git shell on Windows

This is a step by step guide to help you getting started with git on Windows.

Git

Git logo

Install the git shell

There is a fresh Github gui for Windows as well as many other graphic interfaces, but, git was designed to be used from a shell: remember that it was the version control system that Linus Torvalds wrote to develop Linux.

It is much more expressive using it from command line, and to mock up a gui with all those features and options would be completely insane.

So, use the ghost in the shell.

Go to Git for Windows platform download page and get the last installer: at the time of this writing is

Git-1.8.5.2-preview20131230.exe

just hit the Next button and trust defaults.

Configuration

All the following commands should be launched from a git shell.

Basics

First of all, know your current configuration.

git config --list

Add your user name and email, for instance

git config --global user.email "fibo@users.noreply.github.com"
git config --global user.name "fibo"
The email used in the commands is the default email you get from GitHub. Of course you need to set your actual email as well as your name, do not use fibo

SSH public key based authentication

This step is not required, but, it is really usefull. You can generate an ssh key to bypass authenitcation prompt, i.e. insert your username and password everytime you push to remote server.

Create an ssh key

You need an ssh key if you want to authenticate easily on a web-based hosting service, like GitHub.

ssh-keygen -t rsa -C "fibo@users.noreply.github.com"

By now I just hit enter three times, even when prompted for a passphrase.

For more information about passphrase see: Working with SSH key passphrases.

Add your ssh key on your hosting service

You need to copy the content of you id_rsa.pub. The easiset way to copy it, if you have the clip.exe command is

clip < $HOME/.ssh/id_rsa.pub

which will copy your public key to the clipboard so you can edit your hosting service’s account preferences and paste it after you add a new ssh key.

For example, on GitHub is under the SSH keys profile settings menu.

Check it

You can check your ssh key is working, using ssh -T, for instance

$ ssh -T git@github.com
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of know
n hosts.
Hi fibo! You've successfully authenticated, but GitHub does not provide shell ac
cess.

or even

$ ssh -T git@bitbucket.org
conq: logged in as fibo.  You can use git or hg to connect to Bitbucket. Shell access is disabled.
If the check above does not work, probably your firewall does not allow connections on port 22.

Read Bypass restrictive firewall settings instructions to work around it.