Integrating Git in Sublime Text

Original author: Chris Sevilleja
  • Transfer


Accelerating your workflow and increasing productivity is very important for developers. When we work, every second counts, and the time that we spend on solving everyday tasks (such as working with git) ideally could be saved and spent more productively. In this article, we will look at a way to speed up work with Git by integrating it directly into Sublime Text.

Below you can see an example of how fast Git works in conjunction with Sublime.



Requirements


Let's see what we need in order to speed up the process of working with Git.

Please note : if you are installing Git on Windows, make sure that you selected the option " Run Git from the Windows Command Prompt " during installation . All remaining settings can be left by default.



Git command line


Usually, when I work in Sublime text and want to commit, I open a command prompt and print the following:

git add -A
git commit -m 'some crazy stupid message here'
git push



Now, let's save our precious time and do the same through Sublime text.

Git in Sublime Text Editor


If you open the command window (ctrl + shift + p) after installing the plugin and type " git ", you will see the available commands for working with Git.



One of the advantages of the Sublime command line over the terminal is its autocomplete support. Now you don’t have to type the entire long git add -A command, just type “ add ”, which in turn also saves time.



Commit VS Quick Commit


It should be noted that the Git plugin provides 2 ways to commit. Their main difference is that " Quick commit " will open a small window in which it is enough to enter the text of the commit, and " Commit " will open a separate file in which changes will also be displayed in the project.

Below you can see Quick commit and commit in action.

Quick Commit


Commit

After editing the commit text, just close the file.

Add, Commit, and Push in Sublime Text


If I need to send all the changes to the server, the whole process looks like this:

ctrl + shift + p , type add
ctrl + shift + p , type quick , then type the text of the commit
ctrl + shift + p , type push



Tip : if you want to add all changes and commit them in one step, just use the " Quick Commit " command . She will be the equivalent of a team
git commit -am "добавляем изменения и коммитим!"


Conclusion


Just try to work with git this way and you will see how much time you can save. In addition, it should be noted that the functionality of the plugin is not limited to commit and push commands - there are also other commands that allow, for example, to operate with branches. I highly recommend that you familiarize yourself with all the features of the plugin in order to ensure the most comfortable and fast work with Git.

UPD

They told me here that you can configure hot keys for all three commands through Key Bindings:

{ "keys": ["super+shift+plus"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Git: Add..."} },
{ "keys": ["alt+shift+plus"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Git: Commit"} },
{ "keys": ["ctrl+shift+plus"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Git: Push"} },
{ "keys": ["ctrl+shift+ü"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "HG: Quick Commit"} }

Also popular now: