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 reposi
.gitattributes
a file or a folder ? How do I create it ?Windows : Create a new text file (Right click>new>text file) within windows explorer and rename it (Shortcut : F2
) as follows
.gitattributes.
Note : That is DOT
+ gitattributes
+ DOT
, windows will remove the trailing DOT
for you producing the appropriate filename
Unix : and it's variants (Ubuntu, Raspberrian, Mac OS etc.)
touch .gitattributes
Alternatively : Clone the Git Attributes repository and move/copy the .gitattributes
file that is applicable to your repository (Footnote 1 and 2).
X:\PATH\TO\Repository\
, or the Git folder, X:\PATH\TO\Repository\.git\
?There are two locations where one can add the Git attributes file
\Repository (1)
\Repository\.git\info\attributes (3)
.gitattributes
file here sets the attributes "Universally"..gitattributes
file here sets the attributes "Personally", that is the repository upon one's own machine. While inadvisable you may a have good reason for doing so .Provided the file is committed to the repository, it will be cloned when the repository is cloned and the attributes enforced upon the machines of the the contributors of ones project accordingly (Footnote : 3 and 4).
Attributes are applied "Globally " when .gitattributes
is added to the project root, X:\PATH\TO\Repository\.gitignore
, and "Locally" when added to some sub-folder, X:\PATH\TO\Repository\SOME\SUB-FOLDER\.gitignore
.
Footnote(s) :
.gitattributes
for you when you setup tracking..gitattributes
handles this well but it is better for each contributor to configure git properly upon their own machines..gitattributes
to the .gitignore
file. Yes this will apply the attributes "Personally" but some one will overwrite your workaround "Globally" one day and there will be tears and hugging... a lot of hugging !!!