Git is considered one of the most popular, easiest, robust and distributed version control system. This tutorial will cover about know how of GIT over windows, some basic commands and a sample project data to get you started with.
Following things will be needed while setting up GIT over windows :
Windows OS (We have used Windows 7 and it might work on XP and Vista too)
Active internet connection : For downloading package, signup and work on repository
Basic knowledge of operating your OS, software installation and browsing internet.
Step One: Account Signup
To setup GIT for our work, we have to register an account on GIT server.
You can visit https://git.wiki.kernel.org/index.php/GitHosting to get list of GIT Hosting services.
We have used github as example in rest of the tutorial, although procedure will be almost same in every case. Now as we assume you have registered and activated your account at GIT Server, we may proceed with installation part of GIT Software on client side.
Step Two: Installation
After successful registration of account on GIT server we will need to setup client side application for GIT. One of the most popular Windows Git package and the one that works out of the box is mysysgit. You can choose to download the latest version of installer from here http://code.google.com/p/msysgit/
Download and run setup. We assume you have knowledge of running an installer. Here are some screenshots for the same.
Special Note: The main things to check in the installer are : to check for “windows shell integration” for easier access and for “Git bash only” to stay away from any conflicts from HOME and PATH system variables in Windows.
Special Note: You must select “checkout Windows style and commit Unix style” to avoid line-ending errors while committing or checking out.
Once that is done, the installation will be completed. To get started with your new project, goto any folder on windows and right click to select “Git BASH here”.
This will open up the bash prompt of Git. To setup Git to work with your new project, you have to make 3 basic settings.:
1 Register your email address.
2 Register your nickname
3 Generate your public key with your email address
To do so, you have to type the following commands in the Git bash window, that we had opened earlier:
For Registering email Address:
git config --global user.email Your.Email@domain.com
For Registering nickname
git config --global user.name "Your Real Name"
For generating public key with your registered email ID
ssh-keygen -C "email@example.com" -t rsa
Accept the default key file location. When prompted for a passphrase, make one up and enter it. If you feel confident that your own machine is secure, you can use a blank passphrase, for more convenience and less security. Note where it is told you to store the file. On our tutorial machine, it was stored in “C:\Users\username\.ssh\”
Open the file id_rsa.pub with a text editor. id_rsa.pub contain your “public SSH key”. You will need it while setting up your GitHub account. Now as you might have setup the whole thing we should proceed to third step for setting a GITHUB account.
Step 3: Setting up GITHUB Account
First you will need to setup your public SSH Key with server. To do so, open the id_rsa.pub file in a text editor and copy paste content to SSH Keys under Github Account Setting
Once that is done, you can either fork an existing project from Github or create and host your own repo at Github. We are taking the example of the latter case, and then you can create a new project and repository like this :
Once this is done, again go to any folder in your Windows OS and right click it and select “Git GUI here”, thist will bring up a new window for a new project.
Select “Create New Repository” and that will bring up a new window.
In the source location, you have to copy paste the URL of the new Github repository that we had just created. Even for an already existing project that you want to fork, you can easily find the URL like this:
Copy the URL from there and paste it and type the name of a new folder along with location and Git will be setup to work with that folder:
That’s it. Your Git setup is done.
STEP 4: Saving your Code changes/Commit
Now as you have setup the GIT Client, your next move should be to fire up your favorite code editor, make your changes to your code and save your file. Always remember, whenever there is a changes in code, you have to right click on your project folder. It will show you the changes that you have done and will give you the option to commit those changes locally or to push your changes up to your master repo:
First you have to scan and stage your changes. To commit the changes on repo server, you have to give a meaningful comment for the commit and then it will be successfully committed to your master repo.
TIP: You can view changes on your online account on Github with all your commits alongwith comments.
This was just a simple tutorial to get you started quickly with Git and Github on Windows. Git is very powerful and you’ll be keep getting amazed as much as you play and work with it.