Skip to main content

Idiomatic Git commit message

Source control is a developer’s best friend.
The ability to share code with multiple developers, track changes, and easily roll back when problems arise is indispensable in this distributed world. Reviewing others’ commits and pull requests becomes something worth doing, and suddenly can be done independently. Understanding why something happened months or years ago becomes not only possible but efficient.

A project’s long-term success rests (among other things) on its maintainability, and a maintainer has few tools more powerful than his project’s log. It’s worth taking the time to learn how to care for one properly. What may be a hassle at first soon becomes habit, and eventually a source of pride and productivity for all involved.

The seven rules of a great Git commit message

1. Separate subject from body with a blank line 
2. Limit the subject line to 50 characters 
3. Capitalize the subject line 
4. Do not end the subject line with a period 
5 .Use the imperative mood in the subject line 
6. Wrap the body at 72 characters 
7. Use the body to explain what and why vs. how

How to create the template for the global git commit message

1. Create a template file
$ touch ~/.gitmessage.txt
2. Add the content as below
Subject line (try to keep under 50 characters)

Multi-line description of commit,
feel free to be detailed.

[Ticket: X]
3. Setup global config to point to the new template
$ git config --global commit.template ~/.gitmessage.txt
$ git commit
Source: https://chris.beams.io/posts/git-commit/
Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

Comments

Popular posts from this blog

Testing like a boss

Manual mobile app testing là một công việc không hề dễ dàng, nó đòi hỏi QA/Tester phải giành nhiều thời gian và công sức để có thể verify/qualify được hết tất cả các test case. Đặc biệt khi những yêu cầu như pixel perfect hay khi dữ liệu được combine từ nhiều nguồn khác nhau (API/Cache/Local Database/Sharepreferences), thì thời gian mà QA/Tester bỏ ra để có thể đánh giá được chính xác "development progress" là ko hề nhỏ. Tôi có thể kể ra một số câu hỏi thường gặp khi manual testing mobile app  1. Liệu 2 màu ( ▲ )( ▲ )   (implementation/specs) có thực sự giống nhau? Hãy chỉ ra mã màu của chúng? 2. Textsize là bao nhiêu? Typeface là gì? TextColor, HintColor giá trị như thế nào? Làm sao để trả lời đã tuân theo design specs hay chưa? 3. Khoảng cách giữa 2 view là bao nhiêu pixel? Có đúng specs ko? 4. Làm sao có thể biết được trong một màn hình, dữ liệu lấy từ đâu? (API/Cache/Local Database/Sharepreferences) 5. Làm sao có thể xoá local storage khi cần thiết? 6. Kiể...

[Code Review] Lợi ích và những sai lầm thường thấy

Tôi là một kĩ sư, một kĩ sư công nghệ, thế nên việc hiểu và thực hành code review nó là một trong những công việc hằng ngày của tôi. Tuy nhiên việc thực hành code review một cách hiệu quả thực sự là một thách thức. Việc hiểu những lợi ích và khó khăn trong khi tiến hành code reivew sẽ giúp chúng ta hiểu đúng và có cách tiếp cận phù hợp để mang lại giá trị và lợi ích cao nhất. Các lợi ích nổi bật code review mang lại Improve code quality Thông qua code review chất lượng code base được tăng cường, khi bạn thực hành code review một cách có hiệu quả nó thường dẫn đến một số các kết quả như bạn nhận được nhiều feedback có giá trị từ những đồng nghiệp trong team. Và thông qua các tương tác trao đổi kết quả tất yếu là chất lượng code base của bạn được nâng cao Tìm kiếm và ngăn chặn các lỗi từ sớm Khi code review đã trở thành một thói quen và bạn cảm thấy thích thú với việc đó, thì bạn có thể mang đến rất nhiều lợi ích cho sản phẩm, bạn có thể ngăn chặn các lỗi từ trước khi chúng xuất hiện, th...