Git workflow in PhpStorm

While working on a project versioned with Git, there are several most often performed actions:

  • recording changes to local repository
  • pushing changes to remote repository
  • updating local repository with changes from the remote one

PhpStorm provides graphical interface to easily manage these most important actions. When connected with shortcuts, it becomes quite a powerful tool. In this article I would like to present my Git workflow in PhpStorm based on examples, more specifically on a project including multiple branches.

In my simplest Git workflow I do the following steps:

  1. Update the local repository with changes from the remote one
  2. Make changes
  3. Update the local repository again, I don’t like unnecessary merges
  4. Commit changes to the local repository
  5. Push changes to the remote repository

Points 1 and 3 are easy with PhpStorm, because you just need to press Ctrl+T. This will perform ‘git fetch’ and ‘git commit’ with appropriate options. Point 2 might not be as easy 🙂

When changes are made and my local repository is up to date, I press Ctrl+K and I can perform ‘git commit’ and ‘git push’ with just one action. So now my workflow looks like this:

  1. Ctrl+T
  2. Make changes
  3. Ctrl+T
  4. Ctrl+K
  5. Make some magic in a dialog box opened in the previous point

Simple and fast. Additionally, PhpStorm allows performing some actions before and after a commit. The latter option I use very often to upload modified files to the FTP server. Uploading files to the FTP server can be time consuming, so this speed up my work a bit.

dialog-commit

For actions like switching between branches, merging, pushing and many others I use Find Action dialog, which can be invoked with Ctrl+Shift+A. This solution is well known for example from Sublime Text editor. It’s a nice time saver too.

dialog-action

If I need to use a command line, I open a built-in terminal. A possibility of fast switching between an editor and terminal is important to me, so it is nice that I can use the same shortcut Alt+F12 for both opening and closing terminal, and my cursor is always in the right place.

In this short article I presented some of the features that I have found useful in my favourite IDE.

pluswerk