tags:

views:

31

answers:

1

When I do a git commit on the command line, the associated editor pops up with a template that enables me to type in the commit message. This is all well and good.

However, I wonder if it's possible to instead have that template loaded up with the last commit message, so that I can use that as a basis for my current commit message. The intention is to put task lists inside my commit message and update their status in subsequent commits.

So, is it possible to make git automatically load previous comment in the editor on commit?

+2  A: 

I agree with Novelocrat’s comment that it would be better to keep your task list in a tracked TODO file instead of the commit messages.

Nevertheless, what you wanted is possible:

git commit --reedit-message=HEAD --reset-author

From git-commit(1):

  • -c <commit>
    --reedit-message=<commit>
    Like -C, but with -c the editor is invoked, so that the user can further edit the commit message.

  • -C <commit>
    --reuse-message=<commit>
    Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.

  • --reset-author
    When used with -C/-c/--amend options, declare that the authorship of the resulting commit now belongs of the committer. This also renews the author timestamp.

Using the short option, -c, and an abbreviation of the --reset-author option you can type it like this:

git commit -c HEAD --res
Chris Johnsen