{"thread":{"id":"18972","subject":"Beginner problem with .gitignore","startedAt":"2009-04-20T17:57:11Z","lastAt":"2009-04-21T12:26:14Z","messageCount":5,"participants":["Kai Schlamp","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"111760","messageId":"gsid27$p1$1@ger.gmane.org","threadId":"18972","inReplyTo":null,"subject":"Beginner problem with .gitignore","fromName":"Kai Schlamp","fromEmail":"schlamp@gmx.de","sentAt":"2009-04-20T17:57:11Z","receivedAt":"2009-04-20T17:57:11Z","isPatch":false,"sender":{"key":"schlamp@gmx.de","avatar":"https://gravatar.com/avatar/3bf00f9e031db04407c8b6f74422fa820225c3576b6ee685736bfc9dff93669e?d=mp&s=160"},"body":"Hello.\n\nI have a file called TitleAreaDialog.java in the folder\nmy_path\\org.eclipse.jface\\src\\org\\eclipse\\jface\\dialogs\n\n.git and .gitignore is in the my_path\\ folder (using Git Cygwin on Windows).\n\nNow I everything is ignored from org.eclipse.jface, but not that \nTitleAreaDialog.java\n\nSo I specified the following in .gitignore:\n/org.eclipse.*\n!TitleAreaDialog.java\n\nI also tried it with:\n!Title*, \n!/org.eclipse.jface/src/org/eclipse/jface/dialogs/TitleAreaDialog.java\n\nbut the TitleAreaDialog is always ignored as well.\n\nWhat do I have to do to not ignore this file specifically?\n\nBest regards,\nKai\n"},{"id":"111854","messageId":"49ED8914.9090808@drmicha.warpmail.net","threadId":"18972","inReplyTo":"gsid27$p1$1@ger.gmane.org","subject":"Re: Beginner problem with .gitignore","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-04-21T08:51:32Z","receivedAt":"2009-04-21T08:51:32Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Kai Schlamp venit, vidit, dixit 20.04.2009 19:57:\n> Hello.\n> \n> I have a file called TitleAreaDialog.java in the folder\n> my_path\\org.eclipse.jface\\src\\org\\eclipse\\jface\\dialogs\n> \n> .git and .gitignore is in the my_path\\ folder (using Git Cygwin on Windows).\n> \n> Now I everything is ignored from org.eclipse.jface, but not that \n> TitleAreaDialog.java\n> \n> So I specified the following in .gitignore:\n> /org.eclipse.*\n> !TitleAreaDialog.java\n> \n> I also tried it with:\n> !Title*, \n> !/org.eclipse.jface/src/org/eclipse/jface/dialogs/TitleAreaDialog.java\n> \n> but the TitleAreaDialog is always ignored as well.\n\nBy \"is ignored\", do you mean that git status doesn't show it? git status\ndoes not recurse into subdirectories by default unless there is at least\none tracked file inside.\n\n> \n> What do I have to do to not ignore this file specifically?\n\nHave you ever added that file?\n\nIf you only want to track a few files it's easiest to ignore everything\nand git add those files. Once added they will be tracked no matter what\nthe ignore patterns say.\n\nMichael\n"},{"id":"111868","messageId":"49ED988A.6030504@gmx.de","threadId":"18972","inReplyTo":"49ED8914.9090808@drmicha.warpmail.net","subject":"Re: Beginner problem with .gitignore","fromName":"Kai Schlamp","fromEmail":"schlamp@gmx.de","sentAt":"2009-04-21T09:57:30Z","receivedAt":"2009-04-21T09:57:30Z","isPatch":false,"sender":{"key":"schlamp@gmx.de","avatar":"https://gravatar.com/avatar/3bf00f9e031db04407c8b6f74422fa820225c3576b6ee685736bfc9dff93669e?d=mp&s=160"},"body":"Michael, thanks for the help. Comments below.\n\n> By \"is ignored\", do you mean that git status doesn't show it? \n\nYes, that is what I meant.\n\n> git status does not recurse into subdirectories by default unless there \n> is at least one tracked file inside.\n\nOk. I justed tested this a bit. Let's say I have the following directory \nstructure: \"/a_dir/b_dir/c_dir\"\n\nAnd have a .gitignore with:\n/a_dir\n!/a_dir/b_dir/c_dir/\n\nNow i put a file \"a_file\" in \"c_dir\".\nAnd add the a_file with \"git add /a_dir/b_dir/c_dir/a_file\". Yes, a_file \nis tracked now.\n\nI would have expected (after your information above) that if I create \nanother file \"b_file\" in \"c_dir\" and check \"git status\" that this file \nis on the untracked file list now.\nBut it doesn't show up.\nAnd this makes it quite hard to exclude a whole folder, but only include \none of it's subfolders. I use git gui for commits. And I like it that \nnewly added files show up as untracked files.\nBut in this case those files in those subdiretories won't.\n\nBest regards,\nKai\n"},{"id":"111871","messageId":"49EDB167.1030600@drmicha.warpmail.net","threadId":"18972","inReplyTo":"49ED988A.6030504@gmx.de","subject":"Re: Beginner problem with .gitignore","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-04-21T11:43:35Z","receivedAt":"2009-04-21T11:43:35Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Kai Schlamp venit, vidit, dixit 21.04.2009 11:57:\n> Michael, thanks for the help. Comments below.\n> \n>> By \"is ignored\", do you mean that git status doesn't show it? \n> \n> Yes, that is what I meant.\n> \n>> git status does not recurse into subdirectories by default unless there \n>> is at least one tracked file inside.\n> \n> Ok. I justed tested this a bit. Let's say I have the following directory \n> structure: \"/a_dir/b_dir/c_dir\"\n> \n> And have a .gitignore with:\n> /a_dir\n> !/a_dir/b_dir/c_dir/\n> \n> Now i put a file \"a_file\" in \"c_dir\".\n> And add the a_file with \"git add /a_dir/b_dir/c_dir/a_file\". Yes, a_file \n> is tracked now.\n> \n> I would have expected (after your information above) that if I create \n> another file \"b_file\" in \"c_dir\" and check \"git status\" that this file \n> is on the untracked file list now.\n\nThat's for the case when you don't ignore that dir.\n\n> But it doesn't show up.\n> And this makes it quite hard to exclude a whole folder, but only include \n> one of it's subfolders. I use git gui for commits. And I like it that \n> newly added files show up as untracked files.\n> But in this case those files in those subdiretories won't.\n\nThe problem is the recursive way in which git applies those patterns.\nYour patterns above mean that git never recurses into the subdirs.\n\nIn the example above, you probably want\n\n/a_dir/b_dir/*\n!/a_dir/b_dir/c_dir/\n\nCheers,\nMichael\n\nP.S.: Please don't cull cc:\n"},{"id":"111874","messageId":"gske1o$bnf$1@ger.gmane.org","threadId":"18972","inReplyTo":"49EDB167.1030600@drmicha.warpmail.net","subject":"Re: Beginner problem with .gitignore","fromName":"Kai Schlamp","fromEmail":"schlamp@gmx.de","sentAt":"2009-04-21T12:26:14Z","receivedAt":"2009-04-21T12:26:14Z","isPatch":false,"sender":{"key":"schlamp@gmx.de","avatar":"https://gravatar.com/avatar/3bf00f9e031db04407c8b6f74422fa820225c3576b6ee685736bfc9dff93669e?d=mp&s=160"},"body":"  > The problem is the recursive way in which git applies those patterns.\n> Your patterns above mean that git never recurses into the subdirs.\n> \n> In the example above, you probably want\n> \n> /a_dir/b_dir/*\n> !/a_dir/b_dir/c_dir/\n\nOk, I see. But that way would not ignore other directories in a_dir \nbeside b_dir. For that task I have to use the following in .gitignore:\n\n/a_dir/*\n!/a_dir/b_dir/\n/a_dir/b_dir/*\n!/a_dir/b_dir/c_dir/\n\nThis tends to a quite bloated .gitignore when you have a deep directory \nstructure and don't want to ignore all subfolders.\nI also took a brief look into Mercurial and in my opinion the .hgignore \nis more straightforward. It seems to use regexp on the complete file \npath to find out if the files that should be ignored. So the above four \nlines can be combined to one (and if the directory structure would be \ndeeper, it would also be just a one liner).\nI know that there for sure is a reason for why git uses it's pattern in \n.gitignore (probably a performance thing). But it would be nice to have \nat least an option that it recurses into subdiretories, or uses regexp \nsyntax on the whole file path. Just my two cents.\n\nBest regards,\nKai\n"}]}