How to configure Git in Windows?


This article is explaining whole process to setup/configure Git, using for web repository called GitHub.Through-out this article I will explain the step-by-step walthrough - GitHub.

Learn What is GitHub?


In April-2008, GitHub was launched. GitHub is nothing but Web Based Hosting Service, which provides you to create your
own repositories of softwares etc. GitHub is offering both Free and Paid accounts for 'Open Sources' projects In 2010 it named as 'GitHub Inc.'

GitHub which is running on the software has written in 'Ruby On Rails' To start with GitHub repositories you just need to
install GitHub software :

  1. Git for Windows

  2. Git for Windows7

  3. Git for Linux

  4. Git for Mac



I am going to explain 'How to configure Git for Windows' as rest of above flavore are beyond the scope of this article.

Install Git


For any software its mandatory that you have proper environment and pre-requisite to meet the initial setup of the software.

First of all, I prefer you get registered your self here : GitHub.


In case of our first install to Git for Windows, we need to download the setup.




  • Browse to link : msysgit


    Here you can get more help as this is the project which is maintained by number of developers say volunteers and you can
    also work as a volunteer, if you see any modifcations.



  • Go to Download page

  • Download the latest stable release, I prefer Git netinstall - refer to image

    Git-install



  • Run above install and setup Git in folder say d:/msysgit this is the folder I used to install git and refer
    through-out this article.

  • Create shortcut of Git for your future use


    After install you will be notified on the console Git windows to your next task,

    here I prefer to create a shortcut to your desktop of Pin to your Startup so, you can use later.

    Git-Create Shortcut




    Pining shortcut to TaskBar/Starup - Jusr right click over your desktop Git shirtcut created in above step,
    now pin to whereever you want.

    Git - pinning shortcut


  • Configuring Git settings :

    Next step to configure Git to use with your Windows


    - git config --global user.name "your username"

    - git config --global user.email "your email"

    Git-Config Global

    In above, you are saying Git configuration that just work for the guy with above email and username


  • Now, its time to verify the above config :)


    Go to your user a/c - here you can check the above setting using Notepad or notepadd++

    Git-open config using notepad

    Git-open config using notepad++

    Here, you just need to open '.gitconfig' file by right-clicking either in notepad or in notepad++


    I prefer you to install notepad++ refer to my earlier post 'How to setup notepad++'


  • In above, it is done, if you just want to use Git for your versioning of files. You can leave here,

    and go for my another post How to configure Git Repository?

  • But, if you want to use Git much more as above, do follow these steps :

    MergeTool - a tool merge your changes within branches and files and many more as showing differences between two versions etc.

    I prefer, you to install WinMerge as an external merge tool - refer to my other post How to setup 'WinMerge' for Windows'



    Follow above step to open config file with notepad++

    Now, type following code in your opened document :




    [merge]
    tool = winmerge
    [mergetool "winmerge"]
    cmd winmerge.sh "$BASE" "$LOCAL"
    keepBackup = false
    trustExitCode = false




    Git merge tool



    Above, [merge] - defines a name of external tool i.e winmerge
    $BASE $LOCAL are the macros saying files need to merge, for more detail refer to
    my earlier post 'How to setup 'WinMerge' for Windows''.


  • In above step, we have written winmerge.sh now, we need to add this external command

    Go to your Git installed path, remember we have installed Git at D:/msysgit/

    Git addingwinmergedotsh


    now, right click on winmerge.sh file with notepad++

    git openwinmergerdotshwithnotepad++




    Add following lines in the blank opened document :


    Git setting winmerge arguments





    echo Launching Winmerger $1 $2
    "C:\Program Files (x86)\WinMerge\WinMergeU.exe" -e -u -dl "Original" -dr "Modified" "$1" "$2"



    I am not going in deep explanation of above lines as this is beyond the scope of this article.

    close and save above document.


  • Next step, to tell Git about the external Merge Tool

    Go back and click the Git shortcut to open Git Console Window

    shoot following command there :


    git setting up winmerge as external tool



    set GIT_EXTERNAL_DIFF = winmerge.sh




  • Its all setup here now, you can start you Git repository with the tool Git.

  • To quit from Git Console window just type exit and press enter.





Hope, you enjoyed reading my above article. There are many more about Git. Happy programming!


Article by Gaurav Aroraa
Gaurav is a Microsoft Technology Specialist professional. He has awarded lifetime membership from Computer Society of India (CSI). He has more than 13yrs of experience in the industry. Currently, he is working in the capacity of Solution Architect with an MNC. He is serving to the various communities since 1999.

Follow Gaurav Aroraa or read 149 articles authored by Gaurav Aroraa

Comments

Author: Shuby Arora10 Nov 2011 Member Level: Gold   Points : 1

Really worthful post, wondering for true path. Thanks for sharing such wonderful things

Author: Gaurav Aroraa14 Nov 2011 Member Level: Gold   Points : 0

Thanks Shuby - I always try to post quality article which will help others, follow me for more stuffs.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: