{"thread":{"id":"9133","subject":"executing git from a non git directory","startedAt":"2007-07-22T06:55:33Z","lastAt":"2007-07-22T19:02:29Z","messageCount":4,"participants":["Patrick Aljord","Shawn O. Pearce","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"48096","messageId":"6b6419750707212355q48a934e4n3be0d6111694ad01@mail.gmail.com","threadId":"9133","inReplyTo":null,"subject":"executing git from a non git directory","fromName":"Patrick Aljord","fromEmail":"patcito@gmail.com","sentAt":"2007-07-22T06:55:33Z","receivedAt":"2007-07-22T06:55:33Z","isPatch":false,"sender":{"key":"patcito@gmail.com","avatar":"https://gravatar.com/avatar/8a78bf80fcbf4963401d6b1a7d40feb8a773ec3ce7120db291d2ef9c00093635?d=mp&s=160"},"body":"Hey all,\n\nI have my git directory that is in /path/to/my_git_dir\n\nI would like to check it from another direcory, I tried the following command:\n\n$ git --git-dir=/path/to/my_git_dir status\n\nand\n\n$ GIT_DIR='/path/to/my_git_dir' && git status\n\nbut in both cases I get this error:\nfatal: Not a git repository: '/path/to/my_git_dir'\n\nyet when I do \"$ cd /path/to/my_git_dir && git status\" I do get the results.\n\nAny idea what I'm doing wrong or if there's a way to check a git dir\nfrom a non git dir?\n\nthanx in advance\n\nPat\n"},{"id":"48097","messageId":"20070722070734.GU32566@spearce.org","threadId":"9133","inReplyTo":"6b6419750707212355q48a934e4n3be0d6111694ad01@mail.gmail.com","subject":"Re: executing git from a non git directory","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-22T07:07:34Z","receivedAt":"2007-07-22T07:07:34Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Patrick Aljord <patcito@gmail.com> wrote:\n> I would like to check it from another direcory, I tried the following \n> command:\n> \n> $ git --git-dir=/path/to/my_git_dir status\n> \n> and\n> \n> $ GIT_DIR='/path/to/my_git_dir' && git status\n\nThese are actually the same two commands.  The --git-dir option\njust means \"set GIT_DIR before calling the real command\".\n\nHowever, there are two problems here...\n \n> but in both cases I get this error:\n> fatal: Not a git repository: '/path/to/my_git_dir'\n\nRight.  That's problem number 1.  /path/to/my_git_dir is probably\nnot actually your Git repository.  The git repository is actually in\n\".git\", so you really need to use:\n\n  $ git --git-dir=/path/to/my_git_dir/.git status\n\nHowever, problem number 2 is that status requires a working\ndirectory.  Setting GIT_DIR explicitly like this tells git that\nyou don't have a working directory present.  So status won't work.\n\n> yet when I do \"$ cd /path/to/my_git_dir && git status\" I do get the results.\n\nThat's what you have to do if you want to run git-status.  Or use\na subshell as that won't change your current working directory:\n\n  $ (cd /path/to/my_git_dir && git status)\n\n-- \nShawn.\n"},{"id":"48098","messageId":"20070722071136.GA346@coredump.intra.peff.net","threadId":"9133","inReplyTo":"6b6419750707212355q48a934e4n3be0d6111694ad01@mail.gmail.com","subject":"Re: executing git from a non git directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-22T07:11:37Z","receivedAt":"2007-07-22T07:11:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jul 22, 2007 at 01:55:33AM -0500, Patrick Aljord wrote:\n\n> $ git --git-dir=/path/to/my_git_dir status\n>\n> and\n>\n> $ GIT_DIR='/path/to/my_git_dir' && git status\n>\n> but in both cases I get this error:\n> fatal: Not a git repository: '/path/to/my_git_dir'\n\nA git dir is the location where all of the repository information is\nstored; it is called '.git' for a directory with a working tree. Is\n/path/to/my_git_dir really a git dir, or is it a working directory that\nhas a '.git' inside it?\n\nIf the latter, then you need to specify the .git directory. However,\nrunning 'git-status' won't make any sense then, since you won't be in\nthe correct working tree (so of course it will look like files have been\nremoved).\n\nYou could do something like \"git --dir /path/to/my_git_dir/.git branch\"\nand it would at least produce sensible results.\n\n> yet when I do \"$ cd /path/to/my_git_dir && git status\" I do get the results.\n\nRight. That's the way you have to do it in the case of 'status', since\nyou need your current working directory to be in the right place.\n\nIf you are running a very recent git, you can now try:\n\n  git --work-tree=/path/to/my_git_dir --git-dir=/path/to/my_git_dir/.git status\n\nwhich is what you actually want.\n\n-Peff\n"},{"id":"48167","messageId":"6b6419750707221202t7a5cbafcs5d38ee7a10042247@mail.gmail.com","threadId":"9133","inReplyTo":"20070722071136.GA346@coredump.intra.peff.net","subject":"Re: executing git from a non git directory","fromName":"Patrick Aljord","fromEmail":"patcito@gmail.com","sentAt":"2007-07-22T19:02:29Z","receivedAt":"2007-07-22T19:02:29Z","isPatch":false,"sender":{"key":"patcito@gmail.com","avatar":"https://gravatar.com/avatar/8a78bf80fcbf4963401d6b1a7d40feb8a773ec3ce7120db291d2ef9c00093635?d=mp&s=160"},"body":"ok thanx to both of you Jeff and Shawn for the info.\n\nOn 7/22/07, Jeff King <peff@peff.net> wrote:\n>   git --work-tree=/path/to/my_git_dir --git-dir=/path/to/my_git_dir/.git status\n>\n> which is what you actually want.\n\nok, I'm going to try that, thanx.\n\nPat\n"}]}