📜 ⬆️ ⬇️

How to make commits, so that later it does not hurt

A few days ago, David Demaree, Typekit’s chief Adobe contributor, published a cool git book for people . In order to draw attention to her, he published a squeeze of the most interesting, in my opinion, chapter on how to arrange commits so that the wolves were whole, the sheep were full, and the fox did not come. And for this weekend I prepared a squeeze from a squeeze - a shortened and adapted translation so that you can quickly read and add the most valuable things to your experience.

Commit Art



A comment to a commit is probably the most important part of it, since this is the only place where not only what has been written is written, but why .

- from comments

A good comment on a commit is short. And not only because brevity is a sister. The messages to commits are most often read in the change log, where there will be a lot of them . Consider each message as a news headline on the Internet: it should be short enough so that you can quickly flip through the news and contain just enough information so that you can find important information for you. If you have more than a couple of programmers in the team, then the commit log allows you to be aware of what is happening in the project. Git does not impose restrictions on the length of the message; after a brief announcement, you can add several paragraphs of text:
')
Updated Ruby on Rails version because security Bumped Rails version to 3.2.11 to fix JSON security bug. See also http://weblog.rubyonrails.org/2013/1/8/Rails-3-2-11-3-1-10-3-0-19-and-2-3-15-have-been-released/ 


Please note that the entire message contains quite a lot of information, and the first line contains a short squeeze. Because in the log you will see only the first line:

 commit f0c8f185e677026f0832a9c13ab72322773ad9cf Author: David Demaree Date: Sat Jan 3 15:49:03 2013 -0500 Updated Ruby on Rails version because security 


Your favorite text editor


git integrates with both console editors (vim, emacs) and graphic (Atom, Sublime, TextMate). Invoked without --message git will transfer the text stub to the configured editor. After editing the message, it is enough to save the open file and close the editor, git will determine that the message has been changed and uses it. An example of git integration with Atom:

 $: git config --global core.editor "atom --wait" 


Each editor needs its own command line keys, and in GitHub help you can find a good overview of how to customize popular text editors.

Comment to commit


When you write a comment to a commit, I recommend sticking to the following rules:



Your comments?


I hope this translation will be useful to many habratchiteli. As a developer, I share the opinion of the author and will be happy to discuss in the comments the difficult question of creating a readable commit log.

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


All Articles