简体   繁体   中英

how do I make the default git commit message use CRLF line endings

The default git commit message includes the following:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch testNotepad
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   foo.txt

I have notepad setup as my default editor in git. This message is displayed as a single line due to the fact that line endings are not CRLF. I would like to change this. How can this be done?

git does not support this directly. You will need to use an editor that can handle Unix-style line endings ( \\n ).

However, if your editor of choice does not support this, you can instead set your editor to a proxy that will convert the line endings to Windows-style ( \\r\\n ), invoke your editor, then convert the line endings to Unix-style ( \\n ) for git.

GitPad is the best example of an editor proxy that can accomplish this.

This feature to support notepad may have been added since this question was asked. I was able to repro using version 2.16.1.windows.4.

Opens notepad with no line returns showing:

git config --global core.editor "notepad.exe"

However using this instead worked for me:

git config --global core.editor "notepad"

Just a matter of leaving the .exe off of the end.

Have you tried setting core.autocrlf to true ?

Something like:

git config --global core.autocrlf true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM