#I am using git and all my file changes have ^M in the end, how to get rid of it
1 messages · Page 1 of 1 (latest)
those are carriage returns (see the caret notation column here https://en.wikipedia.org/wiki/ASCII#Control_code_table )
ASCII ( ASS-kee), an acronym for American Standard Code for Information Interchange, is a character encoding standard for representing a particular set of 95 (English language focused) printable and 33 control characters – a total of 128 code points. The set of available punctuation had significant impact on the syntax of computer languages a...
carriage returns make up newlines by default in windows, you may know it as CRLF (carriage return + line feed)
whereas in *nix, the default is LF (line feed)
it's not really an issue
you can configure the line ending in git if you want to make it consistent though
you can add this to a .gitattributes file in the project root
* eol=lf
i usually go with this for all my projects```properties
- text=auto eol=lf
If I set it to LF, the entire file appears changed. So you are telling me M is the default behaviour and just fine? I dont remember that I saw M before
vscocde says its CRLF, while git says its CR(which is M?). I am super confused. How to make it pick CRLF?
I think with CRLF, it will not put the ^M anymore. However I already put core.autocrlf but it still does not work
CRLF is the default for windows, and git/vscode just go along with that.
if you change it to LF, then all the files will change to LF
git is showing the CR as ^M, and the LF and just a newline
2 separate lines have an LF anyways
the ^M is the part that's it's trying to make explicit
is it on every line, or just the last or something like that?
on every line the M appears
ok, then that's a normal windows file i guess, not sure why git is choosing to display that
is it for every file? and what client are you using?
git command line
I wouldnt mind but git says the full file changed with M line endings
I have like 30 lines modified of 300
but git displays all modified
were you previously on *nix or something?
could be wsl
hmm, possibly
so, what i think mightve happened -
- the file was originally commited with LF line endings, possibly from wsl
- the file was now opened in windows and saved as CRLF
- git is choosing to display the ^M to show that it's what changed, instead of having 2 identical lines
you could change the line endings back to LF within your ide to remove the excess changes for now, i guess?
and then make a chore commit to fix your entire repo to either LF or CRLF
warning: in the working copy of 'CuRMiTaggerWork/CuRMiTWcProjLoader.cs', LF will be replaced by CRLF the next time Git touches it
so when does git touch it? in git add?
Please help I am going insane here
not sure about that. i would assume any git operation that involves the file would count as git "touching" it
the files must be CRLF as fas as I can see, since with LF its changed and with M as well. However I have a commit with M changes and I want to commit those changes without M
I already did git reset --soft and I am trying to get rid of M changes. When I do a new change from there, its a M change agaoin
yeah they're being turned into CRLF in your working tree
but the committed version is LF
so why do I have M
because they're currently CRLF when the existing version is LF
M is Cr and not CRLF
yes, because the LF is not changed and not shown
the exisitng version is literally crlf, in the commit its M and when I do new changes its M again
LF ois shown as changed
the change is "LF" -> "CRLF"
instead of showing "LF" -> "CRLF", it's showing the actual part that changed, "<empty>" -> "CR"
what do you mean by change?
going from LF to CRLF, every LF is turned into CRLF
when is turned, on commit? or on server?
it's showing the actual data difference, which is a CR being added
in your working tree, in your local repo
^M, to be specific
it contains LF all the time
caret notation is used to notate control characters
so I have a commit with LF and I need to turn it to CRLF
Tell me how to get there without breaking my keyboard
what's your current git config regarding line endings
core.autocrlf
that's a setting name, not the actual setting
C:\code\test\ag-curmit4>git config core.autocrlf
true
ok, that's turning stuff into crlf
disable it for now
So by disablong it, it will keep it to LF
yeah
then, commit or stash your actual work, so that you don't have any changes in your working tree
then fix the file endings (preferably in all files via config or .gitattributes) and commit that (as a chore, if you're using conventional commits)
I am starting from beginning once again, need to go through 70 files
just let git handle it
I changed file to LF and now the entire file is displayed as changed
displayed where, exactly