4

I want to be able to commit without having to say something about why I am committing. Is there a way to prevent git from committing because I do not fill in a comment. I could do this with SVN without a problem, but I can't with git for some reason.

Ted.

Flethuseo
  • 5,969
  • 11
  • 47
  • 71
  • 7
    Why don't you want anyone to know what you did on a change? Comments on changes usually are important for the understanding. I don't know if it's possible to disable this, but I hope it's well hidden so nobody finds it (easily). – sjngm Aug 20 '11 at 16:26
  • possible duplicate of [Xcode 4 - Git commit with no commit message](http://stackoverflow.com/questions/6218199/xcode-4-git-commit-with-no-commit-message) – Karl Bielefeldt Aug 20 '11 at 20:44
  • 2
    @sjngm Not everyone using git is working on a team - I use it for solo projects and the requirement always to add a commit comment frequently annoys me. For certain type of change, in certain circumstances, there really is no point adding any extra description. – codebox Nov 02 '11 at 10:27

3 Answers3

6

From git-commit manual

git commit --allow-empty-message
Paweł Obrok
  • 22,568
  • 8
  • 74
  • 70
2

Take a look at the answer to this SO question:

Note that, though it might seem annoying at first, it's better to train yourself to actually enter comments. The above question also has links that debate/explain why this might be important.

Community
  • 1
  • 1
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
2

Whilst there are times when one feels like no comment should be necessary, after many years one learns of the regular fallibility of memory. Trying to explain what you did on that particular code commit 6 months from now will be easier if you give yourself a clue.

What this means is that you should have at least have a few standard codewords that you can quickly type to aid later clarification. Here I'm thinking of:

  • "CoB wip" (close of business work in progress), or
  • "marginal" (it works, but only just), or
  • "buggy" (it works somethimes ;-), etc.

Having a few cheat sheet codewords is an easy win that uses almost no effort, and will satisfy all the critics (management, co-workers, reviewers, fellow SO readers;-) and -m"cob wip" is quicker to type & shorter than --allow-empty-message !

Philip Oakley
  • 13,333
  • 9
  • 48
  • 71