Questions tagged [gitattributes]

Git attributes provide the option to set various settings for a set of files/directories.

Git attributes provide the option to set various settings for a set of files/directories, including the option to do it recursively within a path (for all of its children files and directories). Such settings can be: merge strategies, how to identify and diff binary files, how to export repositories, SVN or CVS-style keyword expansion.

268 questions
211
votes
7 answers

How can I make git ignore future revisions to a file?

I have created a default version of a file included in a git repository. It's important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. …
Marc
  • 5,315
  • 5
  • 30
  • 36
172
votes
3 answers

What is the purpose of `text=auto` in `.gitattributes` file?

Mostly .gitattributes file has * text=auto. What is the purpose of text=auto in that file?
Fizer Khan
  • 88,237
  • 28
  • 143
  • 153
109
votes
8 answers

How to normalize working tree line endings in Git?

I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now when I commit changes I get the message: warning: CRLF will be replaced by LF in…
user11171
  • 3,821
  • 5
  • 26
  • 35
81
votes
3 answers

Where should I place my global 'gitattributes' file?

I gather there is (despite the lack of documentation) a way to set Git attributes globally; but I'm not clear where to place the necessary gitattributes file. The instructions say they belong in $(prefix)/etc/gitattributes But where is $(prefix)?…
orome
  • 45,163
  • 57
  • 202
  • 418
66
votes
1 answer

How to to disable Git end-of-line (CRLF to LF) across all clones/machines?

As one can glean from other posts, Git's end-of-line normalization has its pros and cons. I have one particular Windows-only project where I think the best thing to do is to is to disable end-of-line normalization altogether. That is, I want to…
Chris
  • 9,986
  • 8
  • 48
  • 56
48
votes
3 answers

What will `* text=auto eol=lf` in gitattributes do?

We have this in our .gitattributes file: * text=auto eol=lf I'd like to precisely understand what this does. The first part is text=auto. From the documentation: This ensures that all files that Git considers to be text will have normalized (LF)…
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240
46
votes
1 answer

How to create a Git attributes file

I would like to add an attributes file to my Git repository as described here. It indicates that I should include .gitattributes in the root folder of my repository. Is .gitattributes simply a file or is it a folder ? How do I create this…
Carel
  • 3,289
  • 2
  • 27
  • 44
43
votes
1 answer

Using gitattributes for linguist examples

Are there any concrete examples, in order to detect wrong languages in GitHub via Linguist attributes? Source: https://github.com/github/linguist linguist-documentation linguist-language linguist-vendored
Vitali
  • 547
  • 2
  • 6
  • 13
36
votes
2 answers

Add comments/remarks to .gitattributes

Is it possible to add comments or remarks to a .gitattributes file? If yes, how exactly do comment lines look like?
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
31
votes
4 answers

What does "!eol" in gitattributes do?

Recently I came across the following entry in a .gitattributes file: "* text=auto !eol" What does !eol do?
user3226810
  • 319
  • 1
  • 3
  • 3
28
votes
3 answers

How to automatically invoke a script before a git add?

Here's my use case: I commit PNGs and other stuff in my Git repo. I would like to apply a specific process to every PNGs I would like to commit and this is the result of the process I finally want to commit (the potential modified PNG). At the…
Labynocle
  • 4,062
  • 7
  • 22
  • 24
25
votes
5 answers

git smudge/clean filter between branches

There are many related questions involving smudge/clean filters - I have spent some hours reading them, and trying various options, but still failing. I hope I can ask in a way that I get an answer that works for me. Specifically, I have read the…
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255
25
votes
4 answers

Git messed up my files, showing chinese characters in some places

disclaimer: By Git, I mean 'I' messed up. Earlier, I wanted git-gui to show me the diff for which it thinks are binary files. So I made some changes to my .\.gitattributes *.ini text *.inc text But it didn't work. Then I made some…
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
22
votes
3 answers

Can I exclude some files from git-lfs?

I created a repo with some image files. I have .gitignore and .gitattributes that I want to exclude from lfs. So I need to track all files by lfs but not .gitignore and .gitattributes. I' m using Sourcetree and I tried that in…
Max
  • 396
  • 4
  • 13
21
votes
2 answers

How do I set all files in a subdirectory to use a specific eol using gitattributes?

I've been trying to set specific files to always use lf and not crlf regardless of autocrlf on the local system. I tried creating a .gitattributes at the root of the project that only contained SquishIt.Tests/js/*.js eol=lf and I also tried…
Akkuma
  • 2,215
  • 3
  • 16
  • 21
1
2 3
17 18