Sublime is Sublime 4

Now we are heading into our fourth post about sublime. So far we have looked at why we might want to use sublime. We have installed sublime and learned some basic key shortcuts and we have installed a package manager with our first package. In this post we will install git integration into sublime and look at how its used.

This post assumes that the code you have opened in sublime is in a git repository!

So let’s start by installing the git package.

Hit ctrl+shift+p (you should be good at this)
Type install wait for 2-3 seconds
Type git and hit enter to install https://github.com/kemayo/sublime-text-git/wiki

After a few moments the git plugin will be installed. You may or may not need to restart sublime at this point I have heard mixed results.

Now let’s try using our git plugin. Let’s start by being in a file under source control and hitting

ctrl+shift+p git log

You will see the full log of your code. If you select one you can view the commit in a text window.

Let’s try another common one

ctrl+shift+p git pull

This will do a git pull. This is just the very beginning of the integration though. One of my favorite features. Add a new file foo.cs. Then in that file do a

ctrl+shift+p git add (current file)

if you then do a ctrl+shift+p git status you can see that the file has been added. We can also add such fun functionality as ctrl+shift+p blame đŸ™‚

When you want to commit:

ctrl+shift+p git commit

this will bring up a buffer of your commit. Just type it your comment and hit ctrl+w to close the window and commit.

This plugin has very deep git integration including diff viewing and annotating code while working in it! You can find more on its feature set here https://github.com/kemayo/sublime-text-git/wiki

It takes a bit of exploring but you can do quite a bit with git integration in sublime and its language agnostic which is really nice.

While we are on the topic let’s install the github plugin since many of you are probably using github. The package is sublime-github https://github.com/bgreenlee/sublime-github. You can read more about the configuration of the plugin on their website but it allows you to do things like

view on github (opens code in browser)
manage gists (eg file or selection to public gist)
browse gists
gist->clipboard

Overall its quite well done as well.

So now you have gotten full git and github integration into sublime very soon we will start getting into the C# specific stuff but before that we need some better linux specific handling.

4 Comments

  1. Posted March 20, 2014 at 12:01 pm | Permalink | Reply

    On Windows 7, I have cmder installed with cygwin for Git.

    I have just tried doing…

    “ctrl+shift+p git log”

    and I just get

    ‘git’ is not recognised as an internal or external command.

    Do I need to register some system variables for this to work?

    • Posted March 20, 2014 at 12:05 pm | Permalink | Reply

      not sure on windows. in linux ctrl+shift+p is bringing up the command pallette and you are then going to the git plugin I am not sure if this is the same process in windows I would check up the sublime docs.

    • Posted March 20, 2014 at 7:44 pm | Permalink | Reply

      As a comparison, I am having Windows 8 & installed git via chocolatey. the described git plugin works flawlessly.

      • Posted March 21, 2014 at 9:13 am | Permalink

        Your answer made me question it further, and it turns out that basically cmder does not install Git into an expected directory, so Sublime was unable to find it and assumed it was not installed. I tweaked the config to it’s actual location, and all is working well!

        For anybody else who runs into this issue, the details about the config are here:
        https://github.com/kemayo/sublime-text-git/issues/41

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: