1

I have read a number of things about problems related to line endings encoding using git versioning, starting of course by formal documentation like Configuring Git to handle line endings, but also answers about git config --global core.autocrlf setting, such as git commit get fatal error (...) or What's the best CRLF (...) handling strategy with Git? and some more dedicated to the software I use, such as sourcetree line ending issue.

If in most cases these references help greatly to no longer have this kind of problem, this seems unfortunately not the case in the particuliar context of managing a project using WordPress. Indeed, almost every time I switch from one branch to another, various minor changes (that seem to be due to line endings handling) are detected, both by SourceTree and Visual Studio Code.

Setting git config --global core.autocrlf to true or false doesn't seem to make significant changes of behaviour and, despite various attempts, I obviously cannot find the most suitable strategy.

At this time, in order to refine my method, I am trying to set up versionning parameters according to WordPress Coding Standards, by adapting as best as possible settings from .editorconfig file, that can be found in the mirror repository (this project doesn't contain any .gitattributes file that could be used as primary basis).

* text=auto

# Declare files that will always have CRLF line endings on checkout
*.txt                   text eol=crlf
wp-config-sample.php    text eol=crlf

# Declare files that will always have LF line endings on checkout
*.css text eol=lf
*.js  text eol=lf
*.php text eol=lf
*.po  text eol=lf

Despite these adjustments, various changes to be committed continue to be detected when switching branches. For example, when updating to version 5.6, few JavaScript files are detected as such (even if this file type is explicitly indicated in the .gitattributes file).

I cannot determine what is wrong with these settings or what I may have forgotten to set. At first, I thought that this kind of issue might be unique to SourceTree, but as Visual Studio Code's versioning system built-in spots them too, I think these inopportune detections are actually due to a lack of precision in my settings.

I would greatly appreciate if someone who uses git to version a WordPress project could share appropriate and functional settings to avoid these unnecessary detections.

P. Mergey
  • 313
  • 4
  • 18

0 Answers0