📜 ⬆️ ⬇️

Five useful tips when making a commit message

image
So, you are ready to make your great commit, which, of course, makes the code a little better, or fix some bug, or maybe you decided to change the line breaks to Windows / Unix-Style? Naturally, your code is perfect and worthy of all kinds of praise! Bravo! Is your message worthy of your work? Will the descendants be able to make out what you did in a month? In a year? Ten years?



  1. The first line must be 50 characters or less and end with an empty line (\ n \ n). For the Vim editor, there are many plugins for syntax, auto-indenting and file type, which can very easily help with this.
    ')
  2. Add this line to your .vimrc file for spell checking, as well as auto-transition lines to the recommended 72 characters:
    autocmd Filetype gitcommit setlocal spell textwidth=72

  3. Never use flags for the message -m / --message=
    , , :
    git commit -m "Fix login bug"
    :
    -m / --message=
    , , :
    git commit -m "Fix login bug"

    :
    Redirect user after authorization

    chyrius.com/path/to/relevant/card

    The user is redirected to the home page after logging in,
    what is different from the original requested page to the authorization
    forms, it creates some inconvenience of use.

    * Save path in session variable
    * Redirect to the saved path after successful authorization




    Answer a few questions:
    1. Why is this change necessary?
      This question will tell your potential pull request to reviewers what exactly in a commit will make it easier for them to recognize incoherent changes.
    2. How does a commit solve a problem?
      Describe in simple terms your changes:
      "Implemented red-black tree to increase search speed" or "Removed dependency package <such> that caused the problem <description of the problem>".
      If your changes are obvious, then this question is not mandatory.
    3. Do the changes cause side effects?
      Perhaps one of the most important issues, it can indicate the problem of many changes in one commit or branch. One or two connected changes in commit, this is normal, but if there are 5 or 6 of them, it means your commit is doing too much :(

      You and your team must agree in advance on how many changes will fit into one commit / branch as much as possible.




    Include in your message a link to the bug / improvement / discussion of your project. A full link will be more useful than just the bug number, or the name of the discussion topic. Usually links are inserted after the summary on the third line.


    Having a true story from the commit messages in your project, you can increase respect for your work from colleagues, as well as improve the overall quality.

    Special thanks to Tim Pope, who tried to set a new standard for message commits .

    Further thanks to the creator of Git and a strong supporter of good message commits , Linus Torvalds.

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


All Articles