Tutorial

Using Git Inside of Sublime Text to Improve Workflow

Draft updated on Invalid Date
author

Chris on Code

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.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Chris on Code

author

Still looking for an answer?

Ask a questionSearch for more help

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!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.