Friday, July 20, 2012

How to use Git in Sublime Text Editor in window7?

Every body have their own favorite editor. But why there is so much of variation between people in choosing editor?. Each editor have their own list of features which results in choosing different editor  between people based on their satisfaction. Since one year i am using eclipse editor. I used eclipse because it has lot of plugins (for e.g. git, google api) for developing application faster. Since lately i have heard a lot about Sublime Text Editor so i have decided to give a try. So the first thing i thought of doing is using Git in Sublime Text Editor. I will explain from Installing to performing some operation of git in sublime text editor. The following are:
  • Download Sublime Text : For downloading visit  http://www.sublimetext.com/. Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. Since we will be installing in window 7 operating system download the windows version.



Simple click to install Git in your computer. Only one thing during installation to do is Adjusting Path Directory. By default Use Git Bash Only will be selected, change it to Run Git from  the Windows Command Prompt.



  • git-credential-winstore: Those who use git using command line know that when a push is done to remote repository authentication is asked for verification. But when we push using sublime it does not ask for any authentication. So for that download git-credential-winstore and just run once. 
  • Install Package Control in Sublime Text: Now we have to install git plugin in sublime text. But before installing git plugin we need to install Package Control. For installing go to http://wbond.net/sublime_packages/package_control/installation. As what have explained there simple copy and paste in console of sublime which can be opened using shortcut Ctrl + ` or View->Show Console, and then click enter. Your Package Control will be installed in Sublime Text. Now you can install, update, remove plugin (for e.g. git).
  • Install Git Plugin in Sublime Text: In Sublime Text bring up the command palette by Ctrl + Shift + P.  Type Package Control: install and click enter. 


  • Plugin to install: After previous operation a list of plugin appear. Since we want git plugin, type git and the select git plugin to install. After installing to be on the safer side just restart Sublime text.
  • Create a Project: I am assuming that you have a github account and know how to create a new repository in github. So first create a new repository in github named sublime-git-demo.



    • Now first step to do is create a directory sublime-git-demo in your local machine. After that open sublime-git-demo folder using Sublime Text Editor(File->Open Folder).
    • Second step is to perform git init operation using sublime text editor. To perform git init open Command Palette Ctrl + Shift + P and type git: init. 


  • Git Add and Commit Operation: Now create a new file readme and type hello world. To perform commit operation on readme file, first perform git: add operation by opening command palette. After that perform git: commit similarly be opening command palette (Ctrl + Shift + P). It will ask for commit message, type that and press ctrl + w to close that window (if there is other way please let me know). 

  • Git push Operation: Now to push you  need to first add a remote repo using command prompt (for e.g.  run git operation git remote add origin https://github.com/bittudaimary/sublime-git-demo.git through cmd command prompt). I didn't get the option to perform this opertion using sublime. If any one know please let me know. Now in sublime open command palette and perform git: push. Only once it will ask for github username and password. Now check the github website to see if it is updated.
  • Conclusion: This is how i did and used git in sublime text. If there is any better way please let me know.