Thursday, 14 February 2013

Working with GIT - The Basics

The most popular version control systems is GIT and with popularity of github, it is the most commonly used!
This post gives a the basics of GIT use - pulling, adding, pushing into the repository!

  1. GIT ToolsYou can play around with GIT using the popular GIT Bash for windows or directly from Eclipse
    a) GIT Bash - This gives a UNIX type of feel and hence is most popular amongst developers. In order to download this, go to -
    b) Eclipse - When in a project which is attached to a GIT repository, right click on it. You will find a tab called "Team". Within this tab, all the GIT related options can be found.

    The options are discussed briefly below - (a) will contain GIT Bash related options and (b) will be the respective eclipse version of the same
  2. Pull - This is needed to get the project in the same state as the master
    a) GIT Bash - git pull b) Eclipse - Under the "Team" option you will find Pull, that does the same thing
  3. Add - This is required to add all the files you have changed into your local Project. Adding these files wont reflect into the main branch. In order to do so, you need to commit your files and then push them into the master branch.
    a) GIT Bash - i.  git add <file 1> <file 2> ... <file n>
                          ii. git commit -m "My Comment"
                         iii. git push
    b) Eclipse - Under the "Team" option, you need to take the following steps
                          i.  Add to Index - This will open a GUI of all the modified files. Select and add them.
                         ii. Commit - Click this and add a comment for this commit
                        iii. Push - Click this to push all these files to the master branch.
  4. Pull With Modified Files - In case you have modified files in your project and you dont want to commit these to the main branch but you want to pull the changes other team members made to the master branch then use the following commands -
    a) GIT Bash - i.   git stash                      ii.  git pull                      iii. git stash pop

Hope this helps. In case of more information - you know where to go - Google !