As far as I can see, there are two problems here:
The file name must be .gitattributes (with leading s ).
The prefix **/ not understood by git. Just use *.launch to match all files in all subdirectories and /*.launch only to match files in the top level directory.
The following shell script demonstrates the correct use of the text attribute:
#!/bin/bash set -ex rm -rf q22629396 mkdir q22629396 cd q22629396 git init echo '*.txt text' > .gitattributes git add .gitattributes git commit -m 'added .gitattributes' echo -e 'line with LF' > test.txt echo -e 'line with CRLF\r' >> test.txt echo -e 'line with LF' >> test.txt echo -e 'line with CRLF\r' >> test.txt mkdir subdir echo -e 'line with LF' > subdir/test.txt echo -e 'line with CRLF\r' >> subdir/test.txt echo -e 'line with LF' >> subdir/test.txt echo -e 'line with CRLF\r' >> subdir/test.txt git add test.txt subdir/test.txt git commit -m 'added test.txt and subdir/test.txt' git show HEAD:test.txt | hexdump -c git show HEAD:subdir/test.txt | hexdump -c
(Tested with git version 1.7.9.5 on Ubuntu 12.04.)
Additional notes:
The text attribute only corrects line endings when checking files, and not when checking them. And eol=lf prevents automatic conversion to CRLF at checkout, and does not automatically convert CRLF to LF at checkout. Therefore, if the files have CRLFs in them in the repository, you must re-commit with LF.
If you check the file with CRLF and set the text attribute in this file, I should be marked as βmodifiedβ in git status from the very beginning. Now you can run git commit in this file, which will change the line ending in the repository, but not in the working copy.
Resetting a line ending in a working copy file is then difficult. git now replaces the CRLF in the LF file before comparing with the index or repository. Because of this, git does not consider the file to be different from the perfect version and thus does nothing when you use commands such as git checkout -f . The only thing that worked in my tests was to delete the file locally and check it again: rm test.txt; git checkout -- test.txt rm test.txt; git checkout -- test.txt
Clifford vienna
source share