Previous: Initiating a Commit, Up: Committing [Contents][Index]
After initiating a commit as described in the previous section, two new buffers appear. One shows the changes that are about to be committed, while the other is used to write the message.
Commit messages are edited in an edit session - in the background git
is waiting for the editor, in our case emacsclient
, to save the commit
message in a file (in most cases .git/COMMIT_EDITMSG
) and then return.
If the editor returns with a non-zero exit status then git
does not
create the commit. So the most important commands are those for
finishing and aborting the commit.
with-editor-finish
)Finish the current editing session by returning with exit code 0. Git then creates the commit using the message it finds in the file.
with-editor-cancel
)Cancel the current editing session by returning with exit code 1. Git then cancels the commit, but leaves the file untouched.
In addition to being used by git commit
, messages may also be stored
in a ring that persists until Emacs is closed. By default the message
is stored at the beginning and the end of an edit session (regardless
of whether the session is finished successfully or was canceled). It
is sometimes useful to bring back messages from that ring.
git-commit-save-message
)Save the current buffer content to the commit message ring.
git-commit-prev-message
)Cycle backward through the commit message ring, after saving the current message to the ring. With a numeric prefix ARG, go back ARG comments.
git-commit-next-message
)Cycle forward through the commit message ring, after saving the current message to the ring. With a numeric prefix ARG, go back ARG comments.
By default the diff for the changes that are about to be committed are
automatically shown when invoking the commit. To prevent that, remove
magit-commit-diff
from server-switch-hook
.
When amending to an existing commit it may be useful to show either the changes that are about to be added to that commit or to show those changes alongside those that have already been committed.
magit-diff-while-committing
)While committing, show the changes that are about to be committed. While amending, invoking the command again toggles between showing just the new changes or all the changes that will be committed.
• Using the Revision Stack: | ||
• Commit Pseudo Headers: | ||
• Commit Mode and Hooks: | ||
• Commit Message Conventions: |
Previous: Initiating a Commit, Up: Committing [Contents][Index]