📜 ⬆️ ⬇️

Integrating Git into Sublime Text



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

Below you can see an example of how quickly 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 have selected the option " Run Git from the Windows Command Prompt " during the installation. All remaining settings can be left as default.



Git command line


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

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



And now let's save our precious time and do the same thing 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 the support of autocomplete. Now you don’t have to type the whole long “git add -A” command, you just need to 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, which will also display changes in the project.

Below you can see Quick commit and commit in action.

Quick commit


Commit

After editing the commit text, simply close the file.

Add, Commit, and Push to Sublime Text


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

ctrl + shift + p , type add
ctrl + shift + p , type quick , then type 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. It will be equivalent to the team.
 git commit -am "   !" 


Conclusion


Just try to work with git in 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 the commit and push commands - there are also other commands that allow, for example, to operate with branches. I strongly recommend that you familiarize yourself with all the features of the plugin to ensure the most comfortable and fast work with Git.

UPD.

I was prompted here that you can configure hotkeys for all three commands via 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"} } 

Source: https://habr.com/ru/post/233899/


All Articles