{"thread":{"id":"24432","subject":"Git Config Question","startedAt":"2010-07-19T05:04:27Z","lastAt":"2010-08-02T19:13:30Z","messageCount":3,"participants":["Shilpa Kulkarni","Jonathan Nieder","Eyvind Bernhardsen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145782","messageId":"AANLkTin8tW_qiRO57F-yjYHzhUkrZbO1g3L_hmesenGL@mail.gmail.com","threadId":"24432","inReplyTo":null,"subject":"Git Config Question","fromName":"Shilpa Kulkarni","fromEmail":"syk@payasonline.com","sentAt":"2010-07-19T05:04:27Z","receivedAt":"2010-07-19T05:04:27Z","isPatch":false,"sender":{"key":"syk@payasonline.com","avatar":null},"body":"Hi\n\nWe are using git with a centralized repo. Some of the developers are\non windows, some are on linux. The build system (ant & ruby scripts\nare used for build) runs on linux. The server on which the software\nproduct is deployed runs on linux. We see a frequent problem:\n1. Person X clones a repo.\nSo far all is good.\n2. Person Y checks in code (commit & push). Checks in file a, b.\n3. Person X does a 'git pull origin master'. Pull succeeds - however\n'git status' shows file a, b as modified even though person X has done\nnothing with these files. 'git checkout' does not work. Files keep\ngetting showed as modified. If person X wants to commit any changes -\nhe is forced to commit file a & b.\n\nThis happens only sometimes - but it is frequent. It is not specific\nto whether Person Y was on linux or windows. Would having the right\nconfigs solve this problem? Any guidelines on what config we should\nuse?\n\nSomeone has recommended we all use\ncore.safecrlf=false\ncore.autocrlf=false\nBut this would require running dos2unix cmd while running scripts on\nlinux which seems like an overhead.\n\nAre these the only two configs that are important?\n\nAny help is appreciated....\n\n-Shilpa\n"},{"id":"145783","messageId":"20100719055909.GA16276@burratino","threadId":"24432","inReplyTo":"AANLkTin8tW_qiRO57F-yjYHzhUkrZbO1g3L_hmesenGL@mail.gmail.com","subject":"Re: Git Config Question","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-07-19T05:59:09Z","receivedAt":"2010-07-19T05:59:09Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(+cc: Eyvind Bernhardsen, Finn Arne Gangstad)\n\nHi!\n\nShilpa Kulkarni wrote:\n\n> 2. Person Y checks in code (commit & push). Checks in file a, b.\n>\n> 3. Person X does a 'git pull origin master'.\n>\n> Pull succeeds - however\n> 'git status' shows file a, b as modified even though person X has done\n> nothing with these files.\n[...]\n> Someone has recommended we all use\n> core.safecrlf=false\n> core.autocrlf=false\n> But this would require running dos2unix cmd while running scripts on\n> linux which seems like an overhead.\n\nI have not kept up with the latest best practices.  But I suspect\nsomething like the following would work:\n\n1. In .git/config, ~/.gitconfig, or /etc/gitconfig, on Windows:\n\n\t[core]\n\t\tautocrlf = true\n\nSee core.autocrlf in git-config(1).  I think git for windows does this\nautomatically.\n\n2. In .git/config, ~/.gitconfig, or /etc/gitconfig, on Unix:\n\n\t[core]\n\t\tautocrlf = input\n\n3. Convert line-endings in the tracked content.  Something like:\n\n\t$ git status; # make sure there are no untracked files present\n\t$ git rm -fr --cached .; # stop tracking all files\n\t$ git add .; # fix line-endings on all files\n\t$ git commit; # record that you have done so\n\n4. Convert line-endings in the work tree.  Something like:\n\n\t$ git rm -fr .; # remove all tracked files\n\t$ git checkout HEAD -- .; # fetch them back again\n\n5. In .gitattributes, something like:\n\n\t*\tauto\n\t*.sh\tcrlf\n\t*.[ch]\tcrlf\n\t*.jpg\t-crlf\n\nSee gitattributes(5) for details.\n\nHope that helps,\nJonathan\n"},{"id":"146973","messageId":"2BD00E81-C9E9-4733-8F21-F55B4D6D961D@gmail.com","threadId":"24432","inReplyTo":"20100719055909.GA16276@burratino","subject":"Re: Git Config Question","fromName":"Eyvind Bernhardsen","fromEmail":"eyvind.bernhardsen@gmail.com","sentAt":"2010-08-02T19:13:30Z","receivedAt":"2010-08-02T19:13:30Z","isPatch":false,"sender":{"key":"eyvind.bernhardsen@gmail.com","avatar":"https://avatars.githubusercontent.com/u/106762?v=4"},"body":"On 19. juli 2010, at 07.59, Jonathan Nieder wrote:\n\n> Shilpa Kulkarni wrote:\n> \n>> 2. Person Y checks in code (commit & push). Checks in file a, b.\n>> \n>> 3. Person X does a 'git pull origin master'.\n>> \n>> Pull succeeds - however\n>> 'git status' shows file a, b as modified even though person X has done\n>> nothing with these files.\n\nSorry for the late reply.\n\nThe problem is that the files are checked in to the repository with CRLFs intact, but then checked out in a repository that has autocrlf enabled.  The result is that git wants to convert the files to LF, and shows them as modified even though no actual changes have been made.\n\nThis no longer happens with git 1.7.2: autocrlf will not convert files that contain CRLFs in the repository.  To enable forced conversion of text files containing CRLF with 1.7.2 or later, add this line to .gitattributes:\n\n\t*\ttext=auto\n\nFiles that need conversion (a and b in your example) should be checked in in the same commit as the change to .gitattributes.  gitattributes(5) has a recipe for making sure all files are converted.\n\nEyvind\n"}]}