Is there any way to incrementally build commit messages in git?
I'm wondering if it is possible to build git commit messages incrementally, documenting what I'm doing as I make code changes:
- Check out and begin work
- Enter commit message title (i.e. summary)
- Make a code change
- Update my commit message to describe change
- Repeat 3 and 4 until开发者_StackOverflow社区 commit is ready
Is there any mechanism built into git to do this?
git commit
can take a commit message from a file using the -F
option. So, you can do something like this:
# Do some work
$ echo 'Did some work' > commit-msg.txt
# Do some more work
$ echo 'Did some more work' >> commit-msg.txt
$ git commit -F commit-msg.txt
You are supposed to do a commit for every small change you do that requires a message. This is especially easy with a distributed versioning system like git that you are using.
- Check out and begin work
- Make a code change
- Enter commit message and commit
- Repeat 2 and 3
- Push updates
And if you for some reason dislike this pattern and want to do the way you described, just use notepad and append to your message after coding a while and then copy paste it when commiting.
If you really want to do it like this (I don't recommend you to do it that way though), then try this:
- Check out and begin work
- Make some code changes
git commit
- Make some further code changes
git commit --amend
- Repeat 4 & 5
git commit --amend --reset-author
to further reset the timestamp
精彩评论