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 file/folder ?
Windows raises the following errors :
"Can't create a file without a filename"
"You must type a filename"
Where should one add the file ? Under the repository root, X:\PATH\TO\Repository\
, or the Git folder, X:\PATH\TO\Repository\.git\
?
Will the attributes be enforced for other contributors cloning/forking my repository ?
e.g. If I pushed to GitHub or GitLab and some other party pulled down a copy would the attributes I added be enforced upon their machine as well ?
Related : Git Ignore
Note : I'm using TortoiseGit and msysgit on a Windows platform if it helps.
.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 !!!