Windows 10: multi-line Git Commit messages.
In Windows 10, how to do multi-line messages for a Git commit.
Windows 10: multi-line Git Commit messages. |
On Windows 10, my git CLI
version is 2.37.3.windows.1
.
I am describing how do multi-line messages for a Git commit.
A git commit
command, can take one (1) or two (2)
text parameters, like so:
git commit -m "First message."
git commit -m "First message." -m "Detail description."
We can make “Detail description.” a multi-line description as in the
following example: we check in D:\learn-git>some_js_funcs.js
, we
have to issue 3 (three) commands:
⓵ First command, add the file to be checked in (i.e. committed):
D:\learn-git>git add some_js_funcs.js
⓶ Second command, commit with a multi-line description:
D:\learn-git>git commit -m "Major refactoring." -m "Added:"^
"function runAjax( method, ..., errorCallback )."^
"const onAjaxErrorUseDialog = ( xhr, error, errorThrown ) => displayError( xhr, error, errorThrown );"^
"const onAjaxErrorUseForm = ( xhr, error, errorThrown ) => setFormErrorText( errorThrown );"^
""^
"Removed:"^
"function retrieveData( method, endPoint, csrfToken, data, successCallback )"^
"function saveData( endPoint, csrfToken, data, successCallback )"^
""^
"function jsonViewerDialog( jsonData, params ) moved to fullscreen_dialogs.js."^
""^
"Bug fixed:"^
"function clearFormInfoText() -- set '#firstMsg' to ' ' instead of blank."
It should be apparent that we prepare this command in a text editor, and just copy and paste this command to the command line console. Note that:
- Each message is enclosed within a pair of
double quotes, i.e.
"function runAjax( method, ..., errorCallback )."^
. - There is a caret
^
character at the end of each line, except the last line. - THERE MUST BE NOTHING ELSE AFTER THE caret
^
character. A single space did cause a problem for me. -
""^
inserts a blank line into the Git commit description. - There is a blank line follows each text line, again except the last line.
⓷ Third and last command, push to the remote repo:
D:\learn-git>git push -u origin main
The second command will pause twice for our input. The first phase, we
just click on the Paste anyway
button, the second phase, we
just hit the Enter key
– please see illustrations:
The multi-line description as seen in the repo UI:
I took me a few tries to get this working on Windows 10: I document so if I forget, I can look it up later… This would not work on a Linux environment, or at least I have not tested yet. Thank you for reading, I hope you find this useful. Stay safe as always.