Question

I use "git add -p" to stage my changes. What I'd like to be able to do is to accumulate a commit message as I'm examining my changes and then when I call "git commit", it is already filled out for me and allows me to make changes before I commit.

Now, its easy to do with git gui by simply examining the changes and editing the commit message text box accordingly, but I'm a command line guy and was wondering if this is possible at the command line.

Was it helpful?

Solution

git add doesn't offer that functionality, but you could try some other options:

  • use git commit -v to have the diff displayed so you get remembered what you are about to commit
  • make small commits in a private branch, then squash them in a git rebase -i.
  • use another editor to populate .git/COMMIT_EDITMSG. This will be used as a template when you do commit. I believe this way is messy and not much easier than writing down the pieces in a file anywhere and loading when you commit (for vi use `:r filename).

OTHER TIPS

git commit can take a F (or --file) option that specifies that the commit message should be taken from a file. So you could add your changes, update a file in which you record your message, and then pass that filename to git commit -F <file>.

That doesn't sound like exactly what you want, but it could be a decent workaround.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top