git commit best practices

前端 未结 7 1432
半阙折子戏
半阙折子戏 2021-01-30 05:24

I am using git to manage a C++ project. When I am working on the projects, I find it hard to organize the changes into commits when changing things that are related to many plac

相关标签:
7条回答
  • 2021-01-30 06:10

    I try and follow these practices in the order...

    1. A commit must not fail a build. Most important!

    2. It should be made of one logical unit of change - whether a single line/character or a whole file/class with corresponding changes in other parts of code, still following #1.

      What is a logical unit of change? In terms of git, if you can specify the changes in the commit message in least number of characters, in one sentence (without ANDs of-course), and you can not break that description further into smaller units, that I call one unit.

    3. Commit message should clearly specify the essence of the commit.

    4. Commit message should be small, typically no greater than 80 chars. Any more elaboration should be part of the description.

    0 讨论(0)
提交回复
热议问题