Antw: Re: Q: Ignore ./foo, but not script/foo
>>> Sebastian Staudt schrieb am 19.07.2018 um 09:55 in Nachricht : > Hello Ulrich, > > if you want to ignore a file in the root of the repository (and only > there) this is the correct syntax: > > /foo Hi! Thanks, you are perfectly right: It works, and actually, when read carefully enough, the last item in "PATTERN FORMAT" explains that. Maybe the EXAMPLES could have an example for each item (5 cases) described ;-) Regards, Ulrich > > Best regards, > Sebastian > Am Do., 19. Juli 2018 um 09:45 Uhr schrieb Ulrich Windl > : >> >> Hi! >> >> I have a (simple) question I could not answer elegantly from the > gitignore(5) manual page: >> >> A project produces a "foo" binary in the root directory that I want to > ignore (So I put "foo" into .gitignore) >> Unfortunately I found out taht I cannot have a "script/foo" added while > "foo" is in .gitignore. >> So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", > but now "foo" is not ignored any more! >> >> Is there as solution other than:? >> -- >> foo >> !script/foo >> !bla/foo >> #etc. >> -- >> >> If "foo" is one exception to generally using foo elsewhere, it seems to be > counterproductive to have to add exceptions for all the cases that are not > exceptions, while "foo" is the only exception... >> >> Did I miss something? If so, maybe add it to a future manual page. >> >> Regards, >> Ulrich >> >>
Re: Q: Ignore ./foo, but not script/foo
On Thu, Jul 19 2018, Timothy Rice wrote: >> How did you come up with this "./" syntax? > > It is a Unix thing: "./" or just "." refers to the current directory. > > When calling scripts or programs in the current directory from a Unix > command line, it is required to refer to them as, say, "./foo" (not just > "foo") -- unless "." is in your PATH. > > Most people do put "." in their PATH for convenience but it is considered a > little unsafe [1]. > > Personally, I am surprised that gitignore does not understand this > notation. To me, OPs meaning was crystal clear: "./foo" should mean to only > ignore the foo in the repository's root directory. > > [1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default To clarify I was trying to fish for whether we'd accidentally documented "./" somewhere since OP was making references to the docs.
Re: Q: Ignore ./foo, but not script/foo
On Thu, Jul 19, 2018 at 07:06:57PM +1000, Timothy Rice wrote: [...] > Most people do put "." in their PATH for convenience [...] IMO this is a gross overstatement: personally, I know of no person using a Unix-like operation system who does this.
Re: Q: Ignore ./foo, but not script/foo
> How did you come up with this "./" syntax? It is a Unix thing: "./" or just "." refers to the current directory. When calling scripts or programs in the current directory from a Unix command line, it is required to refer to them as, say, "./foo" (not just "foo") -- unless "." is in your PATH. Most people do put "." in their PATH for convenience but it is considered a little unsafe [1]. Personally, I am surprised that gitignore does not understand this notation. To me, OPs meaning was crystal clear: "./foo" should mean to only ignore the foo in the repository's root directory. [1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default ~ Tim
Re: Q: Ignore ./foo, but not script/foo
On Thu, Jul 19 2018, Ulrich Windl wrote: > Hi! > > I have a (simple) question I could not answer elegantly from the gitignore(5) > manual page: > > A project produces a "foo" binary in the root directory that I want to ignore > (So I put "foo" into .gitignore) > Unfortunately I found out taht I cannot have a "script/foo" added while "foo" > is in .gitignore. > So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", > but now "foo" is not ignored any more! > > Is there as solution other than:? > -- > foo > !script/foo > !bla/foo > #etc. The solution is to just do: echo /foo >.gitignore Then it'll ignore the top-level /foo, but nothing else. How did you come up with this "./" syntax? It's not understood by gitignore. From gitignore(5): A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
Q: Ignore ./foo, but not script/foo
Hi! I have a (simple) question I could not answer elegantly from the gitignore(5) manual page: A project produces a "foo" binary in the root directory that I want to ignore (So I put "foo" into .gitignore) Unfortunately I found out taht I cannot have a "script/foo" added while "foo" is in .gitignore. So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", but now "foo" is not ignored any more! Is there as solution other than:? -- foo !script/foo !bla/foo #etc. -- If "foo" is one exception to generally using foo elsewhere, it seems to be counterproductive to have to add exceptions for all the cases that are not exceptions, while "foo" is the only exception... Did I miss something? If so, maybe add it to a future manual page. Regards, Ulrich