Must-Knows for Sitecore Project Git Repos
Or, How To Avoid And Fix Content-Length / Line Ending / CR LF / Corrupt File Issues
Start typing to search...
Or, How To Avoid And Fix Content-Length / Line Ending / CR LF / Corrupt File Issues
Note: If you have a fancy up to date development environment, you may not even need to worry about these details as these issues have been resolved in later versions of TDS. But, if you’re reading this post, it probably already means you screwed up.
First, you want to make sure that git is configured properly in terms of the line endings it applies on checkin and checkout. This helpful article explains almost everything you need to know:
https://help.github.com/articles/dealing-with-line-endings/
A major takeaway from the github guide is that it’s probably best if you have a property configured .gitattributes file in the root of your project directory right from the very beginning.
Your .gitattributes file should contain some or all of the following; particularly the last line:
# Source: https://github.com/HedgehogDevelopment/tds-codegen/blob/master/.gitattributes
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
# Custom for TDS/Sitecore serialization (*IMPORTANT*)
*.item -text
Doing so will ensure that when .item files are pulled into the repo, they won’t get zapped.
A few last protips:
CRLF will be replaced by LF” or vice versa. It’s not always a problem, but it can be for certain types of files.Good luck out there.