{"thread":{"id":"15613","subject":"ignoring files/directories in git","startedAt":"2008-09-21T16:54:01Z","lastAt":"2008-09-22T18:47:37Z","messageCount":12,"participants":["mwolfe38","Boaz Harrosh","Dmitry Potapov","Andreas Ericsson","Alex Riesen","Tim Harper"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"91241","messageId":"19596152.post@talk.nabble.com","threadId":"15613","inReplyTo":null,"subject":"ignoring files/directories in git","fromName":"mwolfe38","fromEmail":"mwolfe38@gmail.com","sentAt":"2008-09-21T16:54:01Z","receivedAt":"2008-09-21T16:54:01Z","isPatch":false,"sender":{"key":"mwolfe38@gmail.com","avatar":null},"body":"\nI'm working on a project by myself and using git mostly just to learn about\nit.\nIn my project I have several directories I do not want to have git ignore.\nOne of them being\ncache/ and the other log/\nI've added them to the .gitignore file which I have in the initial directory\nof the repository\nThe contents of my gitignore are:\n\n.settings\n.cache\ncache/\nlog/\n.project\n\nHowever, if I do \ngit add .\nIt will add the files from cache and log anyways.\nI know git add . will add anything that hasn't been added but shouldn't it\nignore files in .gitignore?\nIf not, what is the point, I would just ignore them manually anyways. \nThe main reason i like doing git add .\nis because i'm using symfony php framework which makes good use of scripts\nwhich generates lots if initial files for you and thus adding one at a time\nwould be a pain.\n\nAny idea what might be going on here?  I thought maybe I had added those\ndirectories before putting them in .gitignore so i used git rm -r to remove\nthem but they still show back up with doing git add .\n\nThanks in advance\n-- \nView this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596152.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"91243","messageId":"48D68216.1080404@panasas.com","threadId":"15613","inReplyTo":"19596152.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2008-09-21T17:19:18Z","receivedAt":"2008-09-21T17:19:18Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"mwolfe38 wrote:\n> I'm working on a project by myself and using git mostly just to learn about\n> it.\n> In my project I have several directories I want to have git ignore. One of\n> them being\n> cache/ and the other log/\n> I've added them to the .gitignore file which I have in the initial directory\n> of the repository\n> The contents of my gitignore are:\n> \n> .settings\n> .cache\n> cache/\n> log/\n\nIf I use \"patches/\" in my .gitignore file and then git-status \nthen I get all these extra files in the \"Untracked files:\" section\nbut if I use plain \"patches\" (No slash at end) then it works. Sounds\nlike a bug to me but it sure is a workaround.\n\n> .project\n> \n> However, if I do \n> git add .\n> It will add the files from cache and log anyways.\n> I know git add . will add anything that hasn't been added but shouldn't it\n> ignore files in .gitignore?\n> If not, what is the point, I would just ignore them manually anyways. \n> The main reason i like doing git add .\n> is because i'm using symfony php framework which makes good use of scripts\n> which generates lots if initial files for you and thus adding one at a time\n> would be a pain.\n> \n> Any idea what might be going on here?  I thought maybe I had added those\n> directories before putting them in .gitignore so i used git rm -r to remove\n> them but they still show back up with doing git add .\n> \n> Thanks in advance\n\nBoaz\n"},{"id":"91331","messageId":"20080921172048.GA3877@blimp.localhost","threadId":"15613","inReplyTo":"19596152.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-09-21T17:20:48Z","receivedAt":"2008-09-21T17:20:48Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"mwolfe38, Sun, Sep 21, 2008 18:54:01 +0200:\n> In my project I have several directories I do not want to have git ignore.\n> One of them being\n> cache/ and the other log/\n> I've added them to the .gitignore file which I have in the initial directory\n> of the repository\n> The contents of my gitignore are:\n> \n> .settings\n> .cache\n> cache/\n> log/\n> .project\n> \n> However, if I do \n> git add .\n> It will add the files from cache and log anyways.\n> I know git add . will add anything that hasn't been added but shouldn't it\n> ignore files in .gitignore?\n\nIt should and indeed it does ignore them:\n\n    $ mkdir ggg && cd ggg\n    $ git init\n    Initialized empty Git repository in /tmp/ggg/.git/\n    $ >a\n    $ mkdir cache log\n    $ touch cache/b\n    $ touch log/c\n    $ echo cache/ >.gitignore\n    $ echo log/ >>.gitignore\n    $ cat .gitignore\n    cache\n    log\n    $ git add .\n    $ git ls-files\n    .gitignore\n    a\n\nWhat is your git version and where have you got it from?\nIs your .gitignore written exactly like this (case, some hidden\nextension, like they do on Windows)? Any invisible characters in\n.gitignore?\n"},{"id":"91246","messageId":"19596620.post@talk.nabble.com","threadId":"15613","inReplyTo":"19596152.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"mwolfe38","fromEmail":"mwolfe38@gmail.com","sentAt":"2008-09-21T17:42:36Z","receivedAt":"2008-09-21T17:42:36Z","isPatch":false,"sender":{"key":"mwolfe38@gmail.com","avatar":null},"body":"\nFixed, by removing the trailing / in the names it will then ignore all files\nin that directory,\nso now i just have\ncache \nlog\ninstead of \ncache/ and log/\n\n\n\n\nmwolfe38 wrote:\n> \n> I'm working on a project by myself and using git mostly just to learn\n> about it.\n> In my project I have several directories I want to have git ignore. One of\n> them being\n> cache/ and the other log/\n> I've added them to the .gitignore file which I have in the initial\n> directory of the repository\n> The contents of my gitignore are:\n> \n> .settings\n> .cache\n> cache/\n> log/\n> .project\n> \n> However, if I do \n> git add .\n> It will add the files from cache and log anyways.\n> I know git add . will add anything that hasn't been added but shouldn't it\n> ignore files in .gitignore?\n> If not, what is the point, I would just ignore them manually anyways. \n> The main reason i like doing git add .\n> is because i'm using symfony php framework which makes good use of scripts\n> which generates lots if initial files for you and thus adding one at a\n> time would be a pain.\n> \n> Any idea what might be going on here?  I thought maybe I had added those\n> directories before putting them in .gitignore so i used git rm -r to\n> remove them but they still show back up with doing git add .\n> \n> Thanks in advance\n> \n\n-- \nView this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596620.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"91247","messageId":"20080921174255.GF21650@dpotapov.dyndns.org","threadId":"15613","inReplyTo":"19596152.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-21T17:42:55Z","receivedAt":"2008-09-21T17:42:55Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Sun, Sep 21, 2008 at 09:54:38AM -0700, mwolfe38 wrote:\n> \n> I've added them to the .gitignore file which I have in the initial directory\n> of the repository\n> The contents of my gitignore are:\n> \n> .settings\n> .cache\n> cache/\n> log/\n> .project\n> \n> However, if I do \n> git add .\n> It will add the files from cache and log anyways.\n> I know git add . will add anything that hasn't been added but shouldn't it\n> ignore files in .gitignore?\n\nIt does ignore files in .gitignore. What version of Git do you use?\nIIRC, some old ones did not like the slash at the end of name.\n\nDmitry\n"},{"id":"91276","messageId":"19599905.post@talk.nabble.com","threadId":"15613","inReplyTo":"19596152.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"mwolfe38","fromEmail":"mwolfe38@gmail.com","sentAt":"2008-09-22T00:06:54Z","receivedAt":"2008-09-22T00:06:54Z","isPatch":false,"sender":{"key":"mwolfe38@gmail.com","avatar":null},"body":"\nI just thought that I would add that the reason is a bug in the 1.5.4.3\nversion that I am using which is the ubuntu 8.04 repository version.\nAccording to some developers, the current version should fix this issue.\n\n\nmwolfe38 wrote:\n> \n> I'm working on a project by myself and using git mostly just to learn\n> about it.\n> In my project I have several directories I want to have git ignore. One of\n> them being\n> cache/ and the other log/\n> I've added them to the .gitignore file which I have in the initial\n> directory of the repository\n> The contents of my gitignore are:\n> \n> .settings\n> .cache\n> cache/\n> log/\n> .project\n> \n> However, if I do \n> git add .\n> It will add the files from cache and log anyways.\n> I know git add . will add anything that hasn't been added but shouldn't it\n> ignore files in .gitignore?\n> If not, what is the point, I would just ignore them manually anyways. \n> The main reason i like doing git add .\n> is because i'm using symfony php framework which makes good use of scripts\n> which generates lots if initial files for you and thus adding one at a\n> time would be a pain.\n> \n> Any idea what might be going on here?  I thought maybe I had added those\n> directories before putting them in .gitignore so i used git rm -r to\n> remove them but they still show back up with doing git add .\n> \n> Thanks in advance\n> \n\n-- \nView this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19599905.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"91284","messageId":"48D74B1C.6020408@panasas.com","threadId":"15613","inReplyTo":"19599905.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2008-09-22T07:37:00Z","receivedAt":"2008-09-22T07:37:00Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"mwolfe38 wrote:\n> I just thought that I would add that the reason is a bug in the 1.5.4.3\n> version that I am using which is the ubuntu 8.04 repository version.\n> According to some developers, the current version should fix this issue.\n> \n> \n[Please don't top-post]\n\nI have 1.6.0.1 I compiled here, and it has the same problem. So it is\na very recent fix\n\n> mwolfe38 wrote:\n>> I'm working on a project by myself and using git mostly just to learn\n>> about it.\n>> In my project I have several directories I want to have git ignore. One of\n>> them being\n>> cache/ and the other log/\n>> I've added them to the .gitignore file which I have in the initial\n>> directory of the repository\n>> The contents of my gitignore are:\n>>\n>> .settings\n>> .cache\n>> cache/\n>> log/\n>> .project\n>>\n>> However, if I do \n>> git add .\n>> It will add the files from cache and log anyways.\n>> I know git add . will add anything that hasn't been added but shouldn't it\n>> ignore files in .gitignore?\n>> If not, what is the point, I would just ignore them manually anyways. \n>> The main reason i like doing git add .\n>> is because i'm using symfony php framework which makes good use of scripts\n>> which generates lots if initial files for you and thus adding one at a\n>> time would be a pain.\n>>\n>> Any idea what might be going on here?  I thought maybe I had added those\n>> directories before putting them in .gitignore so i used git rm -r to\n>> remove them but they still show back up with doing git add .\n>>\n>> Thanks in advance\n>>\n> \n\nBoaz\n"},{"id":"91290","messageId":"20080922085200.GI21650@dpotapov.dyndns.org","threadId":"15613","inReplyTo":"48D74B1C.6020408@panasas.com","subject":"Re: ignoring files/directories in git","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-22T08:52:00Z","receivedAt":"2008-09-22T08:52:00Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:\n> \n> I have 1.6.0.1 I compiled here, and it has the same problem. So it is\n> a very recent fix\n\nI certainly tested 1.6.0.1 and does not have this problem, and it was\nfixed a long time ago:\n\n===\ncommit d6b8fc303b389b026f2bf9918f6f83041488989b\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Thu Jan 31 01:17:48 2008 -0800\n\n    gitignore(5): Allow \"foo/\" in ignore list to match directory \"foo\"\n\n    A pattern \"foo/\" in the exclude list did not match directory\n    \"foo\", but a pattern \"foo\" did.  This attempts to extend the\n    exclude mechanism so that it would while not matching a regular\n    file or a symbolic link \"foo\".  In order to differentiate a\n    directory and non directory, this passes down the type of path\n    being checked to excluded() function.\n\n    A downside is that the recursive directory walk may need to run\n    lstat(2) more often on systems whose \"struct dirent\" do not give\n    the type of the entry; earlier it did not have to do so for an\n    excluded path, but we now need to figure out if a path is a\n    directory before deciding to exclude it.  This is especially bad\n    because an idea similar to the earlier CE_UPTODATE optimization\n    to reduce number of lstat(2) calls would by definition not apply\n    to the codepaths involved, as (1) directories will not be\n    registered in the index, and (2) excluded paths will not be in\n    the index anyway.\n===\n\nThe patch is included in 1.5.5.\n\nDmitry\n"},{"id":"91301","messageId":"48D77643.1090908@panasas.com","threadId":"15613","inReplyTo":"20080922085200.GI21650@dpotapov.dyndns.org","subject":"Re: ignoring files/directories in git","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2008-09-22T10:41:07Z","receivedAt":"2008-09-22T10:41:07Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"Dmitry Potapov wrote:\n> On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:\n>> I have 1.6.0.1 I compiled here, and it has the same problem. So it is\n>> a very recent fix\n> \n> I certainly tested 1.6.0.1 and does not have this problem, and it was\n> fixed a long time ago:\n> \n> ===\n> commit d6b8fc303b389b026f2bf9918f6f83041488989b\n> Author: Junio C Hamano <gitster@pobox.com>\n> Date:   Thu Jan 31 01:17:48 2008 -0800\n> \n>     gitignore(5): Allow \"foo/\" in ignore list to match directory \"foo\"\n> \n>     A pattern \"foo/\" in the exclude list did not match directory\n>     \"foo\", but a pattern \"foo\" did.  This attempts to extend the\n>     exclude mechanism so that it would while not matching a regular\n>     file or a symbolic link \"foo\".  In order to differentiate a\n>     directory and non directory, this passes down the type of path\n>     being checked to excluded() function.\n> \n>     A downside is that the recursive directory walk may need to run\n>     lstat(2) more often on systems whose \"struct dirent\" do not give\n>     the type of the entry; earlier it did not have to do so for an\n>     excluded path, but we now need to figure out if a path is a\n>     directory before deciding to exclude it.  This is especially bad\n>     because an idea similar to the earlier CE_UPTODATE optimization\n>     to reduce number of lstat(2) calls would by definition not apply\n>     to the codepaths involved, as (1) directories will not be\n>     registered in the index, and (2) excluded paths will not be in\n>     the index anyway.\n> ===\n> \n> The patch is included in 1.5.5.\n> \n> Dmitry\n> --\n\nOk I found it. Regular subdirectories it works as you said,\nbut soft-link to a folder does not. Sorry for the noise i didn't\nrealize that in my test it was a simlink and not a full directory.\n\nPlease don't fix it if it will hurt performance, I'm happy with\ncurrent solution as it is. Just maybe a small addition to the\n.gitignore documentation perhaps.\n\nBoaz\n"},{"id":"91304","messageId":"48D78749.3030509@op5.se","threadId":"15613","inReplyTo":"48D77643.1090908@panasas.com","subject":"Re: ignoring files/directories in git","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-22T11:53:45Z","receivedAt":"2008-09-22T11:53:45Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Boaz Harrosh wrote:\n> Dmitry Potapov wrote:\n>> On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:\n>>> I have 1.6.0.1 I compiled here, and it has the same problem. So it is\n>>> a very recent fix\n>> I certainly tested 1.6.0.1 and does not have this problem, and it was\n>> fixed a long time ago:\n>>\n>> ===\n>> commit d6b8fc303b389b026f2bf9918f6f83041488989b\n>> Author: Junio C Hamano <gitster@pobox.com>\n>> Date:   Thu Jan 31 01:17:48 2008 -0800\n>>\n>>     gitignore(5): Allow \"foo/\" in ignore list to match directory \"foo\"\n>>\n>>     A pattern \"foo/\" in the exclude list did not match directory\n>>     \"foo\", but a pattern \"foo\" did.  This attempts to extend the\n>>     exclude mechanism so that it would while not matching a regular\n>>     file or a symbolic link \"foo\".  In order to differentiate a\n>>     directory and non directory, this passes down the type of path\n>>     being checked to excluded() function.\n>>\n>>     A downside is that the recursive directory walk may need to run\n>>     lstat(2) more often on systems whose \"struct dirent\" do not give\n>>     the type of the entry; earlier it did not have to do so for an\n>>     excluded path, but we now need to figure out if a path is a\n>>     directory before deciding to exclude it.  This is especially bad\n>>     because an idea similar to the earlier CE_UPTODATE optimization\n>>     to reduce number of lstat(2) calls would by definition not apply\n>>     to the codepaths involved, as (1) directories will not be\n>>     registered in the index, and (2) excluded paths will not be in\n>>     the index anyway.\n>> ===\n>>\n>> The patch is included in 1.5.5.\n>>\n>> Dmitry\n>> --\n> \n> Ok I found it. Regular subdirectories it works as you said,\n> but soft-link to a folder does not. Sorry for the noise i didn't\n> realize that in my test it was a simlink and not a full directory.\n> \n> Please don't fix it if it will hurt performance, I'm happy with\n> current solution as it is. Just maybe a small addition to the\n> .gitignore documentation perhaps.\n> \n\nIt wouldn't hurt performance (noticeably) to change the lstat()\ncall to a stat() call. It's slightly more work for the kernel,\nbut assuming you don't have tens of thousands of symlinks it\nreally won't make a difference. I'm not sure what other things\nwould break from using stat() instead of lstat() in the exclude\nmatching code though, so it's not so simple as just replacing\nit.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"91306","messageId":"20080922121920.GL21650@dpotapov.dyndns.org","threadId":"15613","inReplyTo":"48D77643.1090908@panasas.com","subject":"Re: ignoring files/directories in git","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-22T12:19:20Z","receivedAt":"2008-09-22T12:19:20Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Mon, Sep 22, 2008 at 01:41:07PM +0300, Boaz Harrosh wrote:\n> \n> Ok I found it. Regular subdirectories it works as you said,\n> but soft-link to a folder does not.\n\nWhy should it? Git does not follow symbolic links regardless whether\nthey point to files or directories. In fact, Git does extra checks to\navoid something like: symlink-to-dir/normal-file to be added as a\nnormal file. There was some discussion about it a couple months ago\n(\"Not going beyond symbolic links\").\n\n\nDmitry\n"},{"id":"91336","messageId":"74FEF67B-4F2F-46D6-9679-97C2C19829F5@gmail.com","threadId":"15613","inReplyTo":"19596620.post@talk.nabble.com","subject":"Re: ignoring files/directories in git","fromName":"Tim Harper","fromEmail":"timcharper@gmail.com","sentAt":"2008-09-22T18:47:37Z","receivedAt":"2008-09-22T18:47:37Z","isPatch":false,"sender":{"key":"timcharper@gmail.com","avatar":"https://gravatar.com/avatar/1a2e0c06c7862ff065ee6b1d53195333a5a0577c040ecb2856a150d8e0b00ecd?d=mp&s=160"},"body":"On Sep 21, 2008, at 11:42 AM, mwolfe38 wrote:\n\n>\n> Fixed, by removing the trailing / in the names it will then ignore  \n> all files\n> in that directory,\n> so now i just have\n> cache\n> log\n> instead of\n> cache/ and log/\n\nFYI, you might try this instead:\n/cache\n/log\n\nIt's more specific, and if you had a file like \"/lib/adapters/log/ \nrotater.rb\", it wouldn't be ignored, whereas it would without the  \nleading slashes.\n\nTim\n"}]}