1

In Windows 11 (even in 10) was written a lot of documentation through a hierarchy of .adoc files and git was used for track controls. Well the project directory was shared to other users where they use Linux.

Now with the git status command appears each .adoc file as modified where if is executed the git diff . command appears all the files as

  • All the current content deleted
  • All the current content added as new but ending with ^M

In other words each file appears having the content deleted (at the top) and re-added (at the bottom) with ^M

Question

  • Is there is a command to remove all these ^M "characters"?

Note

I already did do a research in this network but the solutions proposed is about to "ignore". But is need remove all them.

Goal

Fix and share the current directory to more users with Linux. Therefore the ^M situation should not appear anymore.

6
  • 3
    Welcome to the exciting world of Windows vs Unix line endings, and git's labyrinth of settings to "help" with them... Some relevant reading: stackoverflow.com/questions/3206843/… and stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf and stackoverflow.com/questions/170961/… and stackoverflow.com/questions/3068384/… Commented Nov 13 at 17:34
  • 2
    In case you weren't aware: ^M is a way of displaying ASCII character 0001101 (decimal 13, hex 0D) "Carriage Return", the "CR" part of the "CR+LF" sequence traditionally used by MS-DOS and Windows programs to represent a new line; in contrast to the lone "LF" traditionally used by Unix and Linux programs. So rather than "removing the characters", you want to look for settings or tools to "convert the line endings". Commented Nov 13 at 17:38
  • 1
    stackoverflow.com/a/13154031/7976758 A lot of configuration and then the central command git add --update --renormalize Commented Nov 13 at 17:42
  • 1
    I assume that there is no problem with .adoc files having CRLF line endings even on Linux. Therefore, I in your position would go the path of least resistance and define a .gitattributes entry that specifies that these .adoc files are permitted to have CR at the end. Then you do not have to have this (unnecessary, IMO) commit that normalizes the line endings. Commented Nov 14 at 6:51
  • Thanks to all for the replies and links, soon as I can I am going to read each one Commented Nov 15 at 21:14

1 Answer 1

0

apt-get install dos2unix

or whatever distribution you have there

OR

sed -i 's/\r$//' yourfile.adoc

Sign up to request clarification or add additional context in comments.

1 Comment

Did you ever use the first approach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.