obsidian-git
obsidian-git copied to clipboard
[Bug]: CRLF would be replaced by LF
Describe the bug
Whenever I try to stage files, I get the following notification. I'm on Linux. What should I do?

Relevant errors (if available)
No response
Steps to reproduce
Use this plugin in any Linux machine or VM.
Expected Behavior
No response
Addition context
No response
Operating system
Linux
I think you have some windows files in your vault. May try the solution provided on stackoverflow
I use Obsidian on a Windows computer and an Android phone. I follow the article Using Obsidian Git for the tech unfamiliar (minimal command line usage to set up git. I then use
git config core.autocrlf true
on my root folder. But this is still happening. Do you know why?
@Vinzent03 Hello. Would you mind if I bump this again?
@ooker777 The Stack Overflow answer is to set it to false. You set it to true.
@Vinzent03 the stackoverflow answer you are quoting is for linux users. Windows users should use true because true will convert LF to CRLF.
However, from my own testing, the Obsidian client defaults to LF and automatically converts all CLRF control characters to LF on editing a file.
So regardless of if you are on Windows, Mac, or Linux its best to set git config core.autocrlf false
@Vinzent03 the stackoverflow answer you are quoting is for linux users. Windows users should use
truebecausetruewill convert LF to CRLF.However, from my own testing, the Obsidian client defaults to LF and automatically converts all CLRF control characters to LF on editing a file.
So regardless of if you are on Windows, Mac, or Linux its best to set
git config core.autocrlf false
Solve my problem~👍👍
This is definitely a bug. I have been using autocrlf true for many years as it saves a lot of headache when moving sharing code between different people and on different operating systems. Setting autocrlf false is not an option for me. I have written a small script to convert line endings to lf since Logseq (which lives in the same directory) is, correctly, using crlf for it's line endings.
This plugin only executes git commands like you would on the terminal. So this plugin doesn't affect the line endings. So I'm not quite sure where the issue lies.
My apologies, this is not a bug with the plug in. It's a bug that should be owned by obsidian. This issue should be closed.
This Obsidian Forum post is a feature request to change the current behavior of Obsidian on Linux always using LF endings (give it a Like and maybe they'll fix it).
A different forum post Windows and Mac syncing broken because of newline characters agrees with git config core.autocrlf false as the workaround for now. Maybe the plugin could scan the git output for this warning ("CRLF would be replaced by LF") and print a helpful message?
@jrob wrote:
This is definitely a bug. I have been using
autocrlf truefor many years as it saves a lot of headache when moving sharing code between different people and on different operating systems. Settingautocrlf falseis not an option for me.
You'll want to use git config --local core.autocrlf false. That way the setting will be stored in the .git/config file in your Obsidian repo, and will only apply to that repo, with your global core.autocrlf option applying in every other repo. That's specifically what the --local option is for, so you can have global git configs with sensible defaults and override those defaults on a case-by-case basis for repositories that need a slightly different config. See https://git-scm.com/docs/git-config#FILES for more details.