5

Our current project consists of multiple modules in /modules/. When I work on my current module and i.e. update its README how should I write a commit message for this?

  1. Update README
  2. Update README in module_XYZ
  3. Update README [module_XYZ]
  4. module_XYZ | Update README
  5. Something else?

I think 1. has too less information since the single modules are all structured similar - hence this would be ambiguous. 2 - 4 seem to be better but this means I would always need to add the modulename to the commit message which is somehow redundant, since the actual commit shows which module (file) is affected.

I've read this nice How to Write a Git Commit Message post but it does not mention how to write which module your commit affects.

  • 1
    This is not an answer, but rather a suggestion: I would think hard about separating the modules into their own repositories. Either they are independent, in which case they can easily live in their own repositories, or they are not, in which case commits always apply to the entire conglomerate of modules anyway and there is no point in distinguishing them. – Jörg W Mittag Oct 20 '16 at 10:30
4

When you type git commit, and your editor pops up it will have a bunch of commented lines like:

# modified: foo/bar/baz.py
# modified: foo/bar/quix.py

I've come to prefer simply uncommenting these lines and adding notes on what was changed(I tend to prefer very verbose commit messages, mostly to ease code review). So I end up with commit message that looks something like this:

[ISSUE-XXXX] Refactored SomeClass to conform to internal team stile guide

modified: foo/bar/baz.py
- split bigMethod of SomeClass into smallMethod and tinyMethod
- added docstring to undocumentedMethod
- removed extra whitespace
  • 1
    I'd like to point out that if you are using bitbucket and JIRA, prefixing your git commit message with the JIRA issue like :BUG-1234 will create a hyperlink in bitbucket that you can use to see the issue that necessitated the code change. – dckuehn May 11 '17 at 14:20
0

I generally use same commit message for a particular task, so that later i can find name of files which are used for that task using some git command.

For e.g. my task is "#Task1"

regarding this task i use "#Task1" message for each commit.

But you must not add other files which are not affected under this "#Task1".

0

I started to add the module name as a prefix followed by a colon. This is why:

  • The module states the "context" of the message, so it makes sense to put it in front of the message.
  • Since I am using the common "hist" alias, the "[..]" syntax is already taken present the author.
  • Using a colon is a nice visual separator and also aligns with the "common email practice" to separate a prefix with a colon (e.g "Fwd: .."). It's also normal to start with a upper case word after a colon, so best-practices are still respected.

The result:

* abc1234 2018-10-02 | my-module: Update readme [rudi]
* 1234560 2018-10-01 | other-module: Update readme [rudi]
* 123b123 2018-10-01 | Apply new formating rules [rudi]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.