Tuesday, March 27, 2012

Setting up Git, Git Extensions and GitHub account


This tutorial indeed for people who is not familiar with Git and GitHub and make first steps with this this technology. The tutorial contains following steps:
  • Installing Git and Git Extensions
  • Setting up GitHub account ,SSH keys and repository
  • Working with GitHub repository with Git Extensions
  • Cloning public repository from GitHub


Installing Git and Git Extensions

Git Extensions is an open-source project provides graphical user interface for Git that allows you control Git without using the command line. It's download includes msysgit - implementation of Git for Windows.

Download and run latest build from download page . I use version 2.29 for this tutorial. Follow installation wizard with taking notes below:

When you run installer you get welcome page:


 Go next till you get "Required Software" page:



Since Git Extensions is only graphical tool, it requires Git installed. If you are not sure you have proper git installation, just select option "Install MsysGit". KDiff is a diff/merge tool, not the best one, but free. I recommend you select it as well.

Go next till you get "Select SSH client" page:


Ensure you select "PuTTY". It is an easiest way to work with SSH on Windows.

Go next till you get MsysGit installer running (as part of Git Extensions installation).


Select following settings during installation (it is can be changed after installation).



Finally you get "Complete installation"  page with "Finish" button.


Congratulations! You have Git and Git Extensions installed. Run it!

When you run Get Extensions for fist time, it comes with settings page with error:


Don't be scared, it is normal for first time. Just click "Repair" and fill missing details 




That's it. Now you are ready to work with Git repository.


Setting up GitHub account ,SSH keys and repository

Go to https://github.com/signup/free to set up you free account. Registration process is very simple. If you already have GitHub account, skip this step.

Once you have an account at GitHub, log in and go to your account SSH keys configuration page https://github.com/settings/ssh. If you first time here, you have an empty list.

Now it is time to create your SSH key. You may follow instructions from GitHub, but I want to show you my way.

When we installed Git Extensions, we selected "PuTTY" as SSH client and it resulted with helpful  PuTTY utilities was installed. You may find them in C:\Program Files (x86)\GitExtensions\PuTTY folder (or C:\Program Files\GitExtensions\PuTTY on 32bit Windows)


pageant.exe - PuTTY SSH authentication agent,
plink.exe - PuTTY SSH client,
puttygen.exe - PuTTY SSH key generator.

Run puttygen.exe, click "Generate" button and move mouse over black area while progress is displayed.


This way you generated your SSH key.


Now save private key (you may select passphrase (password) if you want). Note: you have to keep you private key in secret.

Copy text from textbox above - it is your public key.  This is what you put into your GitHub account. You can always get this public key by loading your private key in puttygen. (File > Load private key).

Not it is time to come back to GitHub https://github.com/settings/ssh.


Click "Add SSH key", give a name for this key and copy you public key from puttygen.  Click "Add key" -
SSH Keys list shows your newly created key:


Creating repository is very simple. From main page (https://github.com/) click "New repository", fill the form and click "Create repository" - you will get instructions how to set up Git. You may follow this instructions, or follow my way I used to go.

Working with GitHub repository with Git Extensions.

First of all you have to know your repository url. Take it from GitHub instruction page:



Open Git Extensions and click "Clone repository"



Fill repository url and destination. Then click "Load SSH key".


Select you previously saved private key and click "Load". It might prompt password, if you set up one when saved the private key. 

Loading SSH key required for authentication against GitHub.

Click "Clone". Git Extensions will create destination directory and initialize local git repository there.


Click "OK" - it prompts with "Open repository" dialog.


Click "Yes" - your newly cloned repository will be opened:


Such screen you will see each time you clone an empty repository. Lets do some changes.

Go to repository directory and create new README text file:


You will see there .git folder. Don't modify or delete it. This is actually Git repository. All files and folders beside are only current checked out branch.

Now go back to Git Extensions and click "Commit". You will get commit dialog:


Our newly created file have no persistency in repository, Click "Stage" to "fix" it.


Now it is ready for commit. Put commit message and click "Commit".

Git Extensions shows this first commit in our local repository (red colored label).


But it is not all. Since this is our local repository, we have to deliver our changes to remote repository at GitHub.

Go to menu "Commands" > "Push". It opens "Push" dialog:


Click "Push". Because there is no master branch in remote repository yet, it opens confirmation dialog:


Click "Yes".

Now Git Extensions shows your remote repository branch (green colored label)


Since we have created master branch in GitHub repository, it's page doesn't show Git set up instructions, but all repository related information:


All further commit with this repository are similar to first one. You make changes, stage them, commit and push.

Cloning public repository from GitHub

If you want to clone some public repository from GitHub, you have to follow the same steps as you clone your own repository.  The difference is in  repository url. To obtain repository url go repository page.

There is my repository page for example https://github.com/manishma/IZWebFileManager:


In case you select read only access url, you even don't need to configure SSH key. (You still need it for read-write access).

Authentication failures and loading SSH key

When you open local repository with Git Extensions and want to update or  push you changes from/to remote GitHub repository,  you might fail into authentication error:


It happens if your SSH key has not been loaded yet. Don't panic, click "Load SSH key", select your SSH private key and then click "Retry".

Thank you

I hope you find this tutorial helpful.

If you have any questions, please put your comment here.