Search code examples
gittodocommit-message

Is it a good habit to write TODO to commit message?


I just realized that I prefer writing TODO notes directly in to the latest commit instead of issue tracker, for example:

TODO:
- Remove console.log
- Check that XY works
- ...

For example if I have to switch to another job, finishing it and coming back to this branch I can see what had I left undone, fixing it, commit --amend, removing the TODO statements from the commit message.

Is this a good habit or should I force myself to use the issue tracker and write every little notes there (even if others can see the issue)?


Solution

  • I'd say it is sub-optimal.

    Consider this: if a TODO refers to code it should be next to that piece of code. If you write it in a commit message, it becomes completely detached. How is your fellow programmer to identify where to look when she wants to implement the TODO?

    If a TODO refers not to code, but to infrastructure, documentation, etc., it is much better to maintain a TODO file because it is much easier to

    • find the list of active TODOs
    • move an item to DONE (e.g. simply delete it)

    Imagine you want a list of TODO items. In your approach, can you grep all commit messages? How do you know which TODOs are DONE? A separate file makes this answer super easy.