{"thread":{"id":"65239","subject":"describe with --git-dir and --dirty outside of the repo always says dirty","startedAt":"2026-03-13T19:24:43Z","lastAt":"2026-03-18T17:33:38Z","messageCount":4,"participants":["Thomas Braun","Junio C Hamano","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"538925","messageId":"99f2ba7e-cc5f-4ef5-9b09-85896563346f@virtuell-zuhause.de","threadId":"65239","inReplyTo":null,"subject":"describe with --git-dir and --dirty outside of the repo always says dirty","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2026-03-13T19:02:58Z","receivedAt":"2026-03-13T19:24:43Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"When I do\n\ngit describe --dirty\n\nin clean repo of git.git I get\n\nv2.53.0-522-g67006b9db8\n\nbut when I do it from outside of the repo\n\ncd ..\ngit --git-dir=git/.git describe --dirty\n\nI get\n\nv2.53.0-522-g67006b9db8-dirty\n\nCuriously I can workaround the issue by directly passing the work-tree\n\ngit --work-tree=git --git-dir=git/.git describe --dirty\n\nI suspect 2ed5c8e174 (describe: setup working tree for --dirty, \n2019-02-03) has something to do with that.\n\nWhere should I start digging for a fix?\n\n"},{"id":"538932","messageId":"xmqq8qbv4gnq.fsf@gitster.g","threadId":"65239","inReplyTo":"99f2ba7e-cc5f-4ef5-9b09-85896563346f@virtuell-zuhause.de","subject":"Re: describe with --git-dir and --dirty outside of the repo always says dirty","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-13T20:29:29Z","receivedAt":"2026-03-13T20:29:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n\n> When I do\n>\n> git describe --dirty\n>\n> in clean repo of git.git I get\n>\n> v2.53.0-522-g67006b9db8\n>\n> but when I do it from outside of the repo\n>\n> cd ..\n> git --git-dir=git/.git describe --dirty\n\n\"--git-dir\" tells git \"I am at the root of the working tree, but the\ngit directory that you usually find at \".git\" (or a parent directory\nof where we are) is not where you expect but somewhere else, so I am\ntelling you where it is with this argument.\n\nSo if you are not at the root of the working tree for that working\ntree, \"git --git-dir=git/.git diff\" would report that you have a ton\nof changes to working tree files, and \"describe\" would report that\nyour working tree is dirty.\n\nIn other words, working as intended.\n\nYou can tell where the working tree is (instead of telling the\ncommand that you are at the root of the working tree, when you are\nnot), with the \"--work-tree\" option.\n\n$ git --git-dir=git/.git --work-tree=git describe --dirty\n\n> Where should I start digging for a fix?\n\nBetween the keyboard and the chair ;-)?\n\nPerhaps documentation for \"--git-dir\", GIT_DIR, \"--work-tree\", and\nGIT_WORK_TREE should be studied, and if you find that they are\nlacking, that is something we can fix.\n\nThanks.\n"},{"id":"539079","messageId":"abe9uDp16zOcdzZs@pks.im","threadId":"65239","inReplyTo":"xmqq8qbv4gnq.fsf@gitster.g","subject":"Re: describe with --git-dir and --dirty outside of the repo always says dirty","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-16T08:22:16Z","receivedAt":"2026-03-16T08:22:22Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Mar 13, 2026 at 01:29:29PM -0700, Junio C Hamano wrote:\n> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n> \n> > When I do\n> >\n> > git describe --dirty\n> >\n> > in clean repo of git.git I get\n> >\n> > v2.53.0-522-g67006b9db8\n> >\n> > but when I do it from outside of the repo\n> >\n> > cd ..\n> > git --git-dir=git/.git describe --dirty\n> \n> \"--git-dir\" tells git \"I am at the root of the working tree, but the\n> git directory that you usually find at \".git\" (or a parent directory\n> of where we are) is not where you expect but somewhere else, so I am\n> telling you where it is with this argument.\n> \n> So if you are not at the root of the working tree for that working\n> tree, \"git --git-dir=git/.git diff\" would report that you have a ton\n> of changes to working tree files, and \"describe\" would report that\n> your working tree is dirty.\n> \n> In other words, working as intended.\n> \n> You can tell where the working tree is (instead of telling the\n> command that you are at the root of the working tree, when you are\n> not), with the \"--work-tree\" option.\n> \n> $ git --git-dir=git/.git --work-tree=git describe --dirty\n\nYou can do that, but what you're probably looking for is `-C`:\n\n    $ git -C /path/to/git describe --dirty\n\nAs Junio pointed out, \"--git-dir\" has a different effect, and you\ntypically don't have to use it unless you're doing weird stuff.\n\nPatrick\n"},{"id":"539302","messageId":"9cb575c2-a08a-429d-a7d2-cdceda8389bf@virtuell-zuhause.de","threadId":"65239","inReplyTo":"abe9uDp16zOcdzZs@pks.im","subject":"Re: describe with --git-dir and --dirty outside of the repo always says dirty","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2026-03-18T17:33:23Z","receivedAt":"2026-03-18T17:33:38Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 16.03.2026 um 09:22 schrieb Patrick Steinhardt:\n> On Fri, Mar 13, 2026 at 01:29:29PM -0700, Junio C Hamano wrote:\n>> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n>>\n>>> When I do\n>>>\n>>> git describe --dirty\n>>>\n>>> in clean repo of git.git I get\n>>>\n>>> v2.53.0-522-g67006b9db8\n>>>\n>>> but when I do it from outside of the repo\n>>>\n>>> cd ..\n>>> git --git-dir=git/.git describe --dirty\n>> \"--git-dir\" tells git \"I am at the root of the working tree, but the\n>> git directory that you usually find at \".git\" (or a parent directory\n>> of where we are) is not where you expect but somewhere else, so I am\n>> telling you where it is with this argument.\n>>\n>> So if you are not at the root of the working tree for that working\n>> tree, \"git --git-dir=git/.git diff\" would report that you have a ton\n>> of changes to working tree files, and \"describe\" would report that\n>> your working tree is dirty.\n>>\n>> In other words, working as intended.\n>>\n>> You can tell where the working tree is (instead of telling the\n>> command that you are at the root of the working tree, when you are\n>> not), with the \"--work-tree\" option.\n>>\n>> $ git --git-dir=git/.git --work-tree=git describe --dirty\n> You can do that, but what you're probably looking for is `-C`:\n>\n>      $ git -C /path/to/git describe --dirty\n>\n> As Junio pointed out, \"--git-dir\" has a different effect, and you\n> typically don't have to use it unless you're doing weird stuff.\n\nThanks both Junio and Patrick. The documentation is not lacking and \nfully explains\nthat -C is the way to go. I should have checked first.\n\nMy lameish excuse for originally using --git-dir is that -C which was \nadded in\n44e1e4d67d (git: run in a directory given with -C option, 2013-09-09) \nwas too\nnew back then I added the code originally in 2014.\n\nThomas\n\n"}]}