git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Cygwin: Initial clone of repo containing .gitattributes has modified files

From
RGRaman Gupta <rocketraman@fastmail.fm>
Date
Jun 2, 2009, 12:47 UTC
Message-ID
<4A251F66.2020809@fastmail.fm>

When a repository containing a .gitattributes file, which contains other files with -crlf set is cloned on cygwin, with autocrlf = true, the initial checkout of the working copy sets the line endings for the -crlf files incorrectly (it ignores the .gitattributes, presumably because it hasn't been checked out yet).

After the checkout has been done, git does correctly mark the files with -crlf as "modified" and a simple reset --hard fixes it, but this is very confusing for the user as the user has not done anything -- it is git itself that has "modified" the file by not assigning the correct line endings.

Reproduction recipe (on a cygwin binmode mount):

--------------------------------------------------- $ git --version git version 1.6.1.2 $ git config --global core.autocrlf true $ git config --global core.safecrlf true $ mkdir temp.git; cd temp.git; git init $ cat | unix2dos > file_dos DOS line endings ^D $ cat > file_unix UNIX line endings ^D $ cat > .gitattributes .gitattributes -crlf file_unix -crlf ^D $ git add .gitattributes * $ git commit -m "Test" $ cd .. $ git clone temp.git tempclone.git $ cd tempclone.git $ git status ... # modified: .gitattributes # modified: file_unix ... ---------------------------------------------------

Also, in a related issue, git on cygwin requires .gitattributes itself to be included in .gitattributes, otherwise with safecrlf = true you get:

$ git add .gitattributes fatal: LF would be replaced by CRLF in .gitattributes

(since .gitattributes created with a cygwin editor on a binmode mount uses unix line endings)

Cheers, Raman Gupta

Next: Junio C Hamano
Message 1 of 3 in “Cygwin: Initial clone of repo containing .gitattributes has modified files”
  1. Raman GuptaJun 2, 2009
  2. Junio C HamanoJun 2, 2009
  3. Raman GuptaJun 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.