Improving workflow and increasing productivity is very important to us developers. Every second counts since the time we spend on small tasks adds 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.
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 (
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:
git add -A
git commit -m 'some crazy stupid message here'
git push While this is easy enough, let's cut off 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
p, then you'll see your available Git commands (a ton!).
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:
quick, THEN type message
Quick Commitcommand. 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. Read up
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.
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,