Article explaining why .gitattributes is important for configuring a consistent end of file ending in a git repository used by multiple team members on different OSes.
So we should use this to make life easier for Windows users, mainly? Hmm.
I think this might be helpful for teams who use an heterogeneous set of platforms to checkout and work on their code. Windows is one of them, although in this day and age it’s also possible to configure IDEs to do the right thing.
Another important usecase for .gitattributes is to force some file types to be handled as binary data types instead of text, and thus support different types of diff mechanisms. Case in point, a while back there was a discussion on how to track sqlite databases in a git repository in a way that a) the database file wasn’t mangled, b) git diff actually outputted changes to the database instead of random noise. This stuff is handled at the .gitattributes level.
Think about it this way: by making their lives easier, you make life easier for yourself, too. It doesn’t take a lot of effort to put a proper .gitattributes file in your repo, but in return, you’ll nip any potential future issues from Windows users who are trying to contribute accidentally or unknowingly checking in files with the wrong line endings.
Inb4 “I don’t care about contributions from Windows users anyways”: a lot of apps are multiplatform these days (usually Electron). It’s unreasonable to expect people to do all their coding in Linux and only use Windows for testing, especially when all the tooling already exists on Windows. VS Code will handle a repo with LF line endings just fine as long as you told git not to convert the line endings when checking out.
So we should use this to make life easier for Windows users, mainly? Hmm.
They don’t even use a proper operating system that respects the user. Instead they go for some big tech OS from fucking Microsoft.
I think this might be helpful for teams who use an heterogeneous set of platforms to checkout and work on their code. Windows is one of them, although in this day and age it’s also possible to configure IDEs to do the right thing.
Another important usecase for
.gitattributes
is to force some file types to be handled as binary data types instead of text, and thus support different types of diff mechanisms. Case in point, a while back there was a discussion on how to track sqlite databases in a git repository in a way that a) the database file wasn’t mangled, b)git diff
actually outputted changes to the database instead of random noise. This stuff is handled at the.gitattributes
level.Ok didn’t know that. Seems actually useful in certain scenarios, thank you.
Think about it this way: by making their lives easier, you make life easier for yourself, too. It doesn’t take a lot of effort to put a proper
.gitattributes
file in your repo, but in return, you’ll nip any potential future issues from Windows users who are trying to contribute accidentally or unknowingly checking in files with the wrong line endings.Inb4 “I don’t care about contributions from Windows users anyways”: a lot of apps are multiplatform these days (usually Electron). It’s unreasonable to expect people to do all their coding in Linux and only use Windows for testing, especially when all the tooling already exists on Windows. VS Code will handle a repo with LF line endings just fine as long as you told git not to convert the line endings when checking out.
Yeah it’s a fair point. Thank you.
Mac OS is also a big tech OS and arguably doesn’t respect the user.
Linux is nice but often not an option for devs for circumstantial reasons, such as needing to use a corporate-provided machine for work.