// Tutorial //

Using Git Inside of Sublime Text to Improve Workflow

Draft updated on Invalid Date
Default avatar
By Chris on Code
Developer and author at DigitalOcean.
Using Git Inside of Sublime Text to Improve Workflow

This tutorial is out of date and no longer maintained.

Introduction

Improving workflow and increasing productivity is very important to us developers. Every second counts since the time we spend on small tasks add up. Small tasks like our Git commands are something that we do on a daily basis. Today we’ll be looking at a quick way to improve our Git workflow with our favorite editor,

Sublime Text. Here’s a quick example of how fast Git works within Sublime Text.

Requirements

Let’s run through the things we’ll need to improve our Git workflow real quick.

  • Git (of course)
  • Sublime Text (duh)
  • Sublime Text Git - Install using Package Control (CTRL+SHIFT+P)

Git Installation for Windows User: When installing Git, make sure you select Run Git from the Windows Command Prompt. Everything else can be default settings.

Git Through Command Line

Usually, when I am working in Sublime Text and want to commit some changes, I will switch over to my terminal window and type the following:

  1. git add -A
  2. git commit -m 'Documenting the change made to the files.'
  3. git push

While this is easy enough, let’s cut a few seconds off our workflow and do this within Sublime Text.

Git Within Sublime Text

After installing the Git package, if you open your command palette by using

CTRL+SHIFT+P

Then, you’ll see your available Git commands.

The cool thing is that like all other times you use the command palette, you don’t have to enter the entire command. Sublime Text will autocomplete things for you. So instead of typing

git add -A

You can just type:

add

And Sublime Text will know! Just another way to shave off milliseconds off your workflow.

Commit vs Quick Commit

You will notice that there are two commit commands the Sublime Text Git Plugin provides. The main difference is that Quick Commit will open up a little text box that you can quickly type into while Commit will open a new file and show you the changes in each file. Here’s Quick Commit in action:

Here’s Commit in action:

Just close the file after using

Commit and it will use the message you typed as the commit message!

Add, Commit, and Push Within Sublime Text

My workflow when trying to push code to the server inside of Sublime Text looks like:

  • CTRL+SHIFT+P
  • Type add
  • CTRL+SHIFT+P
  • Type quick
  • Then type message CTRL+SHIFT+P
  • Type push

Staging Files and Committing In One Step: To add and commit all in one step, just skip straight to the Quick Commit command. That will stage and commit for you. It’s the equivalent of git commit -am 'im staging and committing!'. Thanks to Moran Bentzur for the tip in the comments.

More Advanced Usage

There’s so much more you can do with this plugin.

Git Gutter Another cool Git Sublime Text package to use is Git Gutter. It will add icons to the text editor to show which lines have been added or removed in the latest commit.

Conclusion

Try out this workflow and see if you find that it saves you some time. With a quick addition of a Sublime Text package, we’re able to add a ton of functionality into our favorite text editor. There are many more things you can do with this plugin including branching, rebasing, stashing, and more. It’s very fully featured and I definitely encourage all to check it out. For more plugins, here.


Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.

Sign up
About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?
Leave a comment

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!