Properly deal with line endings in WordPress versioning
-
I’m using git for versioning a WordPress installation for maintenance purpose, but 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
totrue
orfalse
doesn’t seem to make significant changes of behaviour and, despite various attempts, I cannot find the most suitable strategy.At this time, in order to refine my settings, 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 (which 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 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.
- The topic ‘Properly deal with line endings in WordPress versioning’ is closed to new replies.