Git – How to commit only a message to GIT

git

Suppose that I have been working on a branch and have committed my work but want to
add a message in the logs of what is next on the todo list for the branch. Times
I might want to do this include:

  • Switching branches to work on something else – need to remind myself of what to do next
  • Weekend
  • Other

Is it possible to commit to git without committing any files? Anyother way to word this: Is it possible to commit only a message to GIT?

Best Answer

Yes. It is possible. I can never remember how to do this and always need to Google (so I am writting a Q/A in hope that this will help me to remember).

The command is:

git commit --allow-empty

The doc for --allow-empty reads:

Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts.

Doc makes sense but isn't easy to search for.