15

We're working on a project with a few people having a Mac, and I am running on Windows. We get some problems with the linebreaks.

I read on GitHub that I could add this:

# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

Into .gitattributes

But should I commit that file to GitHub so the other people with Macs get the same settings?

If it matters, we're coding websites. (PHP, JavaScript files, and stuff).

For the record, I'm the only one with Windows... So yeah, what can I do?

double-beep
  • 5,031
  • 17
  • 33
  • 41
Muqito
  • 1,369
  • 3
  • 13
  • 27

2 Answers2

15

First of all, I recommend reading the documentation first.

It suggests either checking in the .gitattributes file at the root of your repository or inside your local .git folder here: .git/info/attributes.

The latter option will probably have the least impact (if you are the only Windows user).

With this kind of thing I tend to put the onus on whoever 'likes to be different' in the team - e.g. if all but one of the devs are using Mac's and the other is using Windows for example, it should really be up to the guy who is going against the grain to sort out. It's nothing malicious, just fair :-)

ben.snape
  • 1,495
  • 10
  • 21
  • Yeah I know. But I've read the documentation, but can't figure out if that file should be om the git server or not too. – Muqito Feb 26 '13 at 13:58
  • do you mean _literally_ on the git server or `checked in`? – ben.snape Feb 26 '13 at 14:00
  • I'm not very good with Git since I just found out about it. But when I try to make a commit it asks me to upload the file to the server and I did.. it actually solved the problem :O So what should I do ? xD Do I answer my own question or what? – Muqito Feb 26 '13 at 22:36
9

I added this:

# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

and committed it to the GitHub server. So everyone who had this fixed the problems.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Muqito
  • 1,369
  • 3
  • 13
  • 27