Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to write a Git commit message

How to write a Git commit message

Given at a company internal thundertalk.

This talk tells you how to write a Git commit message... or better a starter for a discussion about this topic.

Stefan M.

March 19, 2020
Tweet

More Decks by Stefan M.

Other Decks in Technology

Transcript

  1. Disclaimer: This topic is very subjective! It depends on your

    project setup and how you and your team work!
  2. General rules • Limit the (subject) line to 50 chars

    Create Signaler for easier usage of Signaler pattern Create Signaler for easier usage of Signaler pattern which reduces unexpected error for instance by using a BehaviorSubject instead of a PublishSubject
  3. General rules • Limit the (subject) line to 50 chars

    • Capitalize the (subject) line
  4. General rules • Limit the (subject) line to 50 chars

    • Capitalize the (subject) line Create Signaler create Signaler
  5. General rules • Limit the (subject) line to 50 chars

    • Capitalize the (subject) line • Do not end the (subject) line with a period
  6. General rules • Limit the (subject) line to 50 chars

    • Capitalize the (subject) line • Do not end the (subject) line with a period Create Signaler Create Signaler.
  7. General rules • Limit the (subject) line to 50 chars

    • Capitalize the (subject) line • Do not end the (subject) line with a period • Use the imperative
  8. Imperative? Follows git convention Otherwise we should write everything in

    the past, right? - Merge branch ‘xx’ into master - Revert ‘something’ - Fixed ‘xyz’ - Added ‘something’ - Changed ‘a’ to ‘b’
  9. Imperative! Examples - Refactor subsystem X for readability - Update

    getting started documentation - Remove deprecated methods - Release version 1.0.0 - Fixed bug with Y - Changing behavior of X
  10. Single line vs Multi line Fix ride changes observable Fix

    ride changes observable The ride changes, which are emitted from the Firebase RTD, notify our RideChangeObserver. The observer doesn't had any onError handling for it. Because our observer hadn't implemented any error handling the app crashes if, for instance, we have a poor internet connection. Now I added the error handling in the following way: • Error raise • Catch error and unsubscribe • Subscribe again to get notified over Firebase changes again I decided to fix this in this way because .... Resolves: #123
  11. Single line vs Multi line Fix ride changes observable Fix

    ride changes observable The ride changes, which are emitted from the Firebase RTD, notify our RideChangeObserver. The observer doesn't had any onError handling for it. Because our observer hadn't implemented any error handling the app crashes if, for instance, we have a poor internet connection. Now I added the error handling in the following way: • Error raise • Catch error and unsubscribe • Subscribe again to get notified over Firebase changes again I decided to fix this in this way because .... Resolves: #123 This is the subject line
  12. Questions $ git log $ git log --oneline $ git

    show [HASH] $ git bisect [start|good|bad|reset] $ git blame path/to/file
  13. Questions $ git log $ git log --oneline $ git

    show [HASH] $ git bisect [start|good|bad|reset] $ git blame path/to/file If not: Does it make sense to use multi line commits?
  14. Personal preferences • Follow the ‘general rules’ • Use single

    line commit messages • Multi line isn’t worth the time to investigate in the message
  15. Personal preferences • Follow the ‘general rules’ • Use single

    line commit messages • Multi line isn’t worth the time to investigate in the message BUT! (There is always a but, right?)
  16. Personal preferences • Follow the ‘general rules’ • Use single

    line commit messages • Multi line isn’t worth the time to investigate in the message • Does your team do/allow rebasing in feature branches? ◦ Commit message doesn’t matter. You do a new commit anyways. • Does your team squash the merge? ◦ Maybe multi line messages on the ‘merge’ commit make sense BUT!
  17. But! • Depends on your (teams) commit strategy ◦ Often

    as possible? vs Only once if feature is finished? • Allowing of ‘Apply PR suggestions’ commits ◦ (Personal note: I really hate it!) • Do you allow multiple changes in one commit? ◦ Typo fix is part of a ‘functional implementation’ cause you just found it while doing it • … even more?!