{"thread":{"id":"47202","subject":"why can *some* git commands not be run from within .git directory?","startedAt":"2017-11-14T09:19:10Z","lastAt":"2017-11-14T09:43:57Z","messageCount":3,"participants":["Robert P. J. Day","Bryan Turner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"332525","messageId":"alpine.LFD.2.21.1711140409020.13653@localhost.localdomain","threadId":"47202","inReplyTo":null,"subject":"why can *some* git commands not be run from within .git directory?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2017-11-14T09:18:30Z","receivedAt":"2017-11-14T09:19:10Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"\n  just noticed something i was unaware of -- some git commands can't\nbe run if i'm in the .git directory, while others can. for example,\nif i \"cd .git\", commands like this work just fine:\n\n  $ git show\n  $ git branch\n  $ git log\n\nbut others seem unwilling to determine the \"working tree\":\n\n  $ git status\n  fatal: This operation must be run in a work tree\n  $\n\nand:\n\n  $ git stash list\n  fatal: /usr/libexec/git-core/git-stash cannot be used without a working tree.\n  $\n\nwhat's the distinction between commands that can work this way, and\ncommands that can't?\n\nrday\n\np.s. i will refrain from pointing out the inconsistency in using the\nphrases \"work tree\" and \"working tree\" to mean the same thing, when\nthere is a distinct \"worktree\" entity.\n\n-- \n\n========================================================================\nRobert P. J. Day                                 Ottawa, Ontario, CANADA\n                        http://crashcourse.ca\n\nTwitter:                                       http://twitter.com/rpjday\nLinkedIn:                               http://ca.linkedin.com/in/rpjday\n========================================================================\n"},{"id":"332530","messageId":"CAGyf7-FSHW4DqMXt1043FjmOO8tRQHq=xFGwQgKTK06Gi+a-PA@mail.gmail.com","threadId":"47202","inReplyTo":"alpine.LFD.2.21.1711140409020.13653@localhost.localdomain","subject":"Re: why can *some* git commands not be run from within .git directory?","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2017-11-14T09:38:28Z","receivedAt":"2017-11-14T09:38:42Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On Tue, Nov 14, 2017 at 1:18 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:\n>\n>   just noticed something i was unaware of -- some git commands can't\n> be run if i'm in the .git directory, while others can. for example,\n> if i \"cd .git\", commands like this work just fine:\n>\n>   $ git show\n>   $ git branch\n>   $ git log\n>\n> but others seem unwilling to determine the \"working tree\":\n\nOnce Git finds a .git directory, or determines it's in one, it doesn't\nlook \"higher\"; instead, it runs like it's in a bare clone. That means\nany command that requires a work tree or an index generally won't\nwork. Of course, you can still tell Git where the work tree is and\nthen the commands work fine from the .git directory:\n\nincom@Jael MINGW64 /c/Temp/example/.git (GIT_DIR!)\n$ GIT_WORK_TREE=.. git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\n\nnothing to commit, working tree clean\n\n>\n>   $ git status\n>   fatal: This operation must be run in a work tree\n>   $\n>\n> and:\n>\n>   $ git stash list\n>   fatal: /usr/libexec/git-core/git-stash cannot be used without a working tree.\n>   $\n>\n> what's the distinction between commands that can work this way, and\n> commands that can't?\n>\n> rday\n>\n> p.s. i will refrain from pointing out the inconsistency in using the\n> phrases \"work tree\" and \"working tree\" to mean the same thing, when\n> there is a distinct \"worktree\" entity.\n\nNo you won't, clearly.\n\n>\n> --\n>\n> ========================================================================\n> Robert P. J. Day                                 Ottawa, Ontario, CANADA\n>                         https://urldefense.proofpoint.com/v2/url?u=http-3A__crashcourse.ca&d=DwIBAg&c=wBUwXtM9sKhff6UeHOQgvw&r=uBedA6EFFVX1HiLgmpdrBrv8bIDAScKjk1yk9LOASBM&m=yPGW_MCaDCBECSMjz40m8vsxUhljCB3dnrQ4TBi8PtE&s=-JNZXqYtyY7CIJGy65WWa88Kq7BaelyajFehPQZkvo4&e=\n>\n> Twitter:                                       https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_rpjday&d=DwIBAg&c=wBUwXtM9sKhff6UeHOQgvw&r=uBedA6EFFVX1HiLgmpdrBrv8bIDAScKjk1yk9LOASBM&m=yPGW_MCaDCBECSMjz40m8vsxUhljCB3dnrQ4TBi8PtE&s=-9gIAxcdRGPmIz1rpLLb7nl14azEwoE-fOJ-IxAYi18&e=\n> LinkedIn:                               https://urldefense.proofpoint.com/v2/url?u=http-3A__ca.linkedin.com_in_rpjday&d=DwIBAg&c=wBUwXtM9sKhff6UeHOQgvw&r=uBedA6EFFVX1HiLgmpdrBrv8bIDAScKjk1yk9LOASBM&m=yPGW_MCaDCBECSMjz40m8vsxUhljCB3dnrQ4TBi8PtE&s=prnIhreU-Vhx0V6lRCBQEPbJk2P8bPlHcRFus1X_6wM&e=\n> ========================================================================\n"},{"id":"332531","messageId":"alpine.LFD.2.21.1711140442180.14378@localhost.localdomain","threadId":"47202","inReplyTo":"CAGyf7-FSHW4DqMXt1043FjmOO8tRQHq=xFGwQgKTK06Gi+a-PA@mail.gmail.com","subject":"Re: why can *some* git commands not be run from within .git directory?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2017-11-14T09:43:14Z","receivedAt":"2017-11-14T09:43:57Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"On Tue, 14 Nov 2017, Bryan Turner wrote:\n\n> On Tue, Nov 14, 2017 at 1:18 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:\n> >\n> >   just noticed something i was unaware of -- some git commands can't\n> > be run if i'm in the .git directory, while others can. for example,\n> > if i \"cd .git\", commands like this work just fine:\n> >\n> >   $ git show\n> >   $ git branch\n> >   $ git log\n> >\n> > but others seem unwilling to determine the \"working tree\":\n>\n> Once Git finds a .git directory, or determines it's in one, it\n> doesn't look \"higher\"; instead, it runs like it's in a bare clone.\n> That means any command that requires a work tree or an index\n> generally won't work. Of course, you can still tell Git where the\n> work tree is and then the commands work fine from the .git\n> directory:\n\n  ah, thank you, that clarifies it.\n\nrday\n\n-- \n\n========================================================================\nRobert P. J. Day                                 Ottawa, Ontario, CANADA\n                        http://crashcourse.ca\n\nTwitter:                                       http://twitter.com/rpjday\nLinkedIn:                               http://ca.linkedin.com/in/rpjday\n========================================================================\n"}]}