![]() It's a practice I picked up from the corefx repository. It hard codes the line endings for Windows cmd and batch scripts to CRLF and bash scripts to be LF, so that they can be executed via a file share. Only the first line is strictly necessary. # Force bash scripts to always use LF line endings so that if a repo is accessed # in Unix via a file share from Windows, the scripts will work. # Force batch scripts to always use CRLF line endings so that if a repo is accessed # in Windows via a file share from Linux, the scripts will work. # Set default behavior to automatically normalize line endings. gitattributes file at the root of your repository and set the line endings to be automatically normalised like so: If someone with an incorrect configuration checked in a file, it would not be easily visible in a pull request and you'd end up with a repository with inconsistent line endings. However, you shouldn't rely on people having correctly configured Git installations. This automatically changes the line endings in files depending on the operating system. Git can actually be configured to automatically handle line endings using a setting called autocrlf. ![]() If you've ever seen a phantom file change where there are no visible changes, that could be because the line endings in the file have been changed from CRLF to LF or vice versa. Newline characters often cause problems in Git when you have developers working on different operating systems (Windows, Mac and Linux). I recommend reading the Newline Wikipedia article for more on the subject. All of this has it's origin in typewriters which is pretty amazing given how antiquated they are. Windows uses a Carriage Return (CR) followed by the Line Feed (LF) character, while Unix based operating systems use the Line Feed (LF) alone. If you've studied a little computer science, you'll have seen that operating systems use different characters to represent line feeds in text files. gitattributes file that can control a bunch of Git settings that you should consider adding to almost every repository as a matter of course. If you work with anything vaguely in the Microsoft space with Visual Studio, you probably want the 'Visual Studio'. There is even a whole GitHub repository with nothing but pre-made. gitignore file to exclude files from being checked into your repository. If you've messed with Git for long enough, you're aware that you can use the. Also added a section about Git LFS support on GitHub.gitignore Added some more information about CRLF line endings for.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |