^ M characters in git commit message (git commit -v)

I am having a strange problem when a lot of ^ M characters appear in my git commit message. Please find a screenshot. This does not cause any problems, just causes irritation to read.

enter image description here

Tips appreciated.

+6
source share
3 answers

The "right way" if you use Git in a cross-platform environment, unlike Abhijeet's answer, is:

Find out and CORRECTly configure core.autocrlf settings in each client

Read the local section. Why should I use core.autocrlf = true in Git? as a good starting point

+9
source

This is a new line of Windows. The new lines in both windows and linux are different.

You can remove it with dos2unix.

Various ways to do this: http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/

+5
source

I am in windows and do not want to set autocrlf to true . I worked on the problem by putting the following in my .vimrc

 " settings for git commit messages function GitCommitSettings() %s/^M//g " remove ^M added by git diff syntax sync fromstart " refresh syntax highlight after replace 1 " move to line 1 endfunction au BufNewFile,BufRead COMMIT_EDITMSG call GitCommitSettings() 
0
source

Source: https://habr.com/ru/post/911424/


All Articles