denkwerk TechTalk

Git features in PhpStorm

"Complex projects have a lot of moving parts: you update a lot of places, places are added or deleted. With a clean history, it's much easier to track how we got to that point."

Miguel Franken Software Developer at denkwerk

Atomic commits: making collaborative work more traceable

That's why Miguel advises making what he calls Atomic Commits: When developers make many changes in multiple places in the code, they tend to look at the big picture – and maintain the entire code as one commit. The idea behind atomic commits is to set each change as a separate commit and comment it. At the same time, only those commits that are relevant should be maintained.

This has three decisive advantages: On the one hand, code changes can be better tracked later, and on the other hand, this approach also enables third parties - such as reviewers or other developers – to understand changes. At the same time, atomic commits make it easier to search for bugs in the code. This automatically results in a "clean" commit history from the various processes.

Commit messages as an informative supplement

As support of this technology it is meaningful to attach value to the Commit-Messages, thus the description of the changes: Here all developers record which changes they have made with the respective commit. It is important to be as precise and concise as possible.

"Developers should ask themselves: what are the changes I made in these files?"

Miguel Franken Software Developer at denkwerk

Commits: more complex messages for more complex changes.

A typical commit message would be "Update X to Y" or "Change Color of Element". Of course, the messages may be more complex if there are more complex changes. The commit message must contain all the information to facilitate the review.

To make the changes and messages easy to read and understand, it also makes sense to adhere to previously defined conventions. On the one hand, generally applicable rules can be used - such as formulating the commit message in the imperative. In addition, development teams should define common guidelines: These rules ensure that all important information is included and make it easier to track commits. After all, Miguel joked about the different ways software developers work, "one man's beauty is another man's evil hack."

Interactive rebase for a tidy commit history

To keep the commit history clean, the IDE PhpStorm offers some practical functions: For example, commits can be subsequently changed, added to, moved or deleted using "Interactive Rebase". Miguel recommends making these changes locally before pushing: "Don't push until you're happy with your work."

Changes to commit messages should be recorded by means of so-called "amendments", i.e. additions to the commit message. Here it is not necessary to comment on small things like spelling corrections to the previous message. However, more complex additions or changes can also be recorded in this way. This enables reviewers and developers to track code changes at any time.