Wykorzystujemy jeden plik .gitignore
na cały projekt. Załóżmy ze w naszej aplikacji jest folder runtime, który nie powinien zapamiętywać historii.
WEB_APP_ROOT
|-- runtime
| |-- .gitignore //1
|-- .gitignore //2
gdzie: .gitignore //1
*
.gitignore //2
vendor/
WEB_APP_ROOT
|-- runtime
| |-- .gitkeep
|-- .gitignore //1
gdzie: .gitignore //1
runtime/*
*
Wyżej wymienione podejścia sprawdzają się fajnie kiedy ignorowania ścieżka jest już narzucona lub jest ona typowo do odczytu, wtedy lokalnie trzymacie co chcecie i sobie z tego czytacie/zapisujecie (przykład "userfiles"). Kiedy jednak ścieżka to typowy wymysł aplikacji i nie przetrzymuje ona danych które związane są z aplikacją (np css utworzony z sass) dobrze jest taką ścieżkę tworzyć w trakcie "builda" i w tym procesie nadawać również uprawnienia. Już w czasie wgrywania aplikacji (builda) możemy dostać info, że ścieżka nie istnieje lub nie ma uprawnień do zapisu. Dodatkowo to jak ścieżka wygląda lub gdzie się znajduje może być zależne od środowiska dla którego jest odpalany build
Plik który pozwala konfigurować pracę z gitem. Mozemy okreslic jak ma być "formatowany kod", co nie powinno być "zmieniane" bo to pliki binarne i co mogło by być eksportowane. Na ten moment rekomenduje wykorzystywanie takiego pliku.
# Auto-detect text files, ensure they use LF.
* text=auto eol=lf
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.info text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.test text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.yml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
# Define binary file attributes.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
*.gif binary
*.GIF binary
*.gz binary
*.GZ binary
*.ico binary
*.ICO binary
*.jpg binary
*.JPG binary
*.png binary
*.PNG binary
*.phar binary
*.PHAR binary
*.exe binary
*.EXE binary
*.ttf binary
*.TTF binary
*.otf binary
*.OTF binary
*.eot binary
*.EOT binary
*.woff binary
*.woff2 binary
*.WOFF2 binary
*.swf binary
*.SWF binary
*.db binary
*.DB binary
*.tar binary
*.tgz binary
*.TAR binary
*.pdf binary
*.PDF binary
*.jar binary
*.JAR binary