# Adding a commit message to the index

4 messages from 2010-09-18 to 2010-09-19. Participants: Cameron Hutchison, Joshua Juran, Ævar Arnfjörð Bjarmason, Jakub Narebski.
Thread: https://gitlist.dev/t/25146

## Cameron Hutchison, 2010-09-18 22:38

Subject: Adding a commit message to the index
Message-ID: <3347.4c955dd6.4a79e@getafix.xdna.net>
URL: https://gitlist.dev/e/3347.4c955dd6.4a79e%40getafix.xdna.net

```
Is it possible to add a commit message to the index, and have it used as
the final commit message, or as the template for the final commit
message?

Witnessing AKPM's ongoing efforts on linux-kernel to get better commit
messages out of people, it seems it would be beneficial to be able to
stage a commit message and refine it over the course of the development
of the commit. The first cut is rarely the best, so being able to refine
a commit message as one can refine a commit by incrementally using the
index seems like a good idea.

I know I can use git-commit -F and store my commit message outside of
git, but it would be nice to have it in the index with the code it
comments on. That would make the commit and the message stay together
with git-stash for example. Apply this to other index-modifying
operations too.

```

## Joshua Juran, 2010-09-19 01:29

Subject: Re: Adding a commit message to the index
Message-ID: <7AA1261F-8DDD-4599-9A11-753334634DB2@gmail.com>
URL: https://gitlist.dev/e/7AA1261F-8DDD-4599-9A11-753334634DB2%40gmail.com
In-Reply-To: <3347.4c955dd6.4a79e@getafix.xdna.net>

```
On Sep 18, 2010, at 5:48 PM, Cameron Hutchison wrote:

> Is it possible to add a commit message to the index, and have it  
> used as
> the final commit message, or as the template for the final commit
> message?
>
> Witnessing AKPM's ongoing efforts on linux-kernel to get better commit
> messages out of people, it seems it would be beneficial to be able to
> stage a commit message and refine it over the course of the  
> development
> of the commit. The first cut is rarely the best, so being able to  
> refine
> a commit message as one can refine a commit by incrementally using the
> index seems like a good idea.

One of the reasons for having a local repo is so you can check in work  
in progress without committing it to public history.

If you're ready to write a commit message, then make a commit.  You  
can refine it incrementally with `git commit --amend`.

Also, consider making multiple fine-grained commits, and then use  
interactive rebase to squash them into fewer larger commits (and edit  
commit messages) as appropriate.  It's a lot easier to squash fine  
commits than to split course ones.

To summarize:  Commit first, answer questions later.

Josh

```

## Ævar Arnfjörð Bjarmason, 2010-09-19 12:19

Subject: Re: Adding a commit message to the index
Message-ID: <AANLkTinbgTx=ihy82zPRvsv-WvdeEPt0fX+arCQaKnUr@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinbgTx%3Dihy82zPRvsv-WvdeEPt0fX%2BarCQaKnUr%40mail.gmail.com
In-Reply-To: <3347.4c955dd6.4a79e@getafix.xdna.net>

```
On Sun, Sep 19, 2010 at 00:48, Cameron Hutchison <lists@xdna.net> wrote:
> Is it possible to add a commit message to the index, and have it used as
> the final commit message, or as the template for the final commit
> message?

What Joshua suggests is better, but you can abuse git-commit by
writing a commit message to e.g. .git/MERGE_MSG, then the message will
be used at the next 'git commit'.

But just commiting /now/ and squashing/rebasing later is a much better
workflow.

```

## Jakub Narebski, 2010-09-19 13:38

Subject: Re: Adding a commit message to the index
Message-ID: <m362y1luqg.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m362y1luqg.fsf%40localhost.localdomain
In-Reply-To: <3347.4c955dd6.4a79e@getafix.xdna.net>

```
Cameron Hutchison <lists@xdna.net> writes:

> Is it possible to add a commit message to the index, and have it used as
> the final commit message, or as the template for the final commit
> message?
[...]

Why not use commit message templates?

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
