{"thread":{"id":"11725","subject":"What's a \"work tree\"?","startedAt":"2008-01-24T19:09:33Z","lastAt":"2008-01-25T21:56:54Z","messageCount":4,"participants":["Mike","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"66508","messageId":"4798E26D.3040707@talkingspider.com","threadId":"11725","inReplyTo":null,"subject":"What's a \"work tree\"?","fromName":"Mike","fromEmail":"fromlists@talkingspider.com","sentAt":"2008-01-24T19:09:33Z","receivedAt":"2008-01-24T19:09:33Z","isPatch":false,"sender":{"key":"fromlists@talkingspider.com","avatar":null},"body":"\nI'm trying to figure out what a \"work tree\" is.  as in --work-tree. \nThis is a new command right, the tutorials I've read don't have it. The \nman page has the syntax but I don't know what it's for.\n\n$ cd /www/mysitedocroot\n$ git --git-dir /gitdir/mysitegit/ add .\nfatal: add must be run in a work tree\n\nthanks\n"},{"id":"66541","messageId":"20080125061421.GC21973@coredump.intra.peff.net","threadId":"11725","inReplyTo":"4798E26D.3040707@talkingspider.com","subject":"Re: What's a \"work tree\"?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-25T06:14:21Z","receivedAt":"2008-01-25T06:14:21Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 24, 2008 at 02:09:33PM -0500, Mike wrote:\n\n> I'm trying to figure out what a \"work tree\" is.  as in --work-tree. This \n> is a new command right, the tutorials I've read don't have it. The man \n> page has the syntax but I don't know what it's for.\n\nThe work tree is the place where your checked out files reside. E.g.,\nin an ordinary repo (made with \"git init\" or \"git clone\") everything\nthat isn't in the .git directory.\n\n> $ cd /www/mysitedocroot\n> $ git --git-dir /gitdir/mysitegit/ add .\n> fatal: add must be run in a work tree\n\nYou are using --git-dir to point to a repository directory that isn't\n\".git\". That's OK, and it will generally assume that your current\ndirectory is the work tree. E.g., this works:\n\n  mkdir repo && cd repo\n  git init\n  mv .git mygitdir\n  touch file\n  git --git-dir=mygitdir add file\n\nHowever, there is a config option \"core.bare\" which indicates that a\nrepository is \"bare\", meaning that it has no work tree (and that is\npresumably what's happening in your example). So you could use\n--work-tree=. to override that in your example (though you might just be\nbetter off setting config.bare to false).\n\nThe more probable use case for --work-tree is something like\n\n  $ cd /gitdir/mysitegit\n  $ git --work-tree=/www/mysitedocroot add .\n\ni.e., you are in the git dir, so you specify the work tree rather than\nthe other way around. You could even do this:\n\n  $ cd /some/other/directory\n  $ git --git-dir=/gitdir/mysitegit --work-tree=/www/mysitedocroot add .\n\nalthough I'm not sure it's that useful.\n\n-Peff\n"},{"id":"66596","messageId":"479A4C9F.3070200@talkingspider.com","threadId":"11725","inReplyTo":"20080125061421.GC21973@coredump.intra.peff.net","subject":"Re: What's a \"work tree\"?","fromName":"Mike","fromEmail":"fromlists@talkingspider.com","sentAt":"2008-01-25T20:54:55Z","receivedAt":"2008-01-25T20:54:55Z","isPatch":false,"sender":{"key":"fromlists@talkingspider.com","avatar":null},"body":"\n\nJeff King wrote:\n> On Thu, Jan 24, 2008 at 02:09:33PM -0500, Mike wrote:\n> \n>> I'm trying to figure out what a \"work tree\" is.  as in --work-tree. This \n>> is a new command right, the tutorials I've read don't have it. The man \n>> page has the syntax but I don't know what it's for.\n> \n> The work tree is the place where your checked out files reside. E.g.,\n> in an ordinary repo (made with \"git init\" or \"git clone\") everything\n> that isn't in the .git directory.\n> \n>> $ cd /www/mysitedocroot\n>> $ git --git-dir /gitdir/mysitegit/ add .\n>> fatal: add must be run in a work tree\n> \n> You are using --git-dir to point to a repository directory that isn't\n> \".git\". That's OK, and it will generally assume that your current\n> directory is the work tree. E.g., this works:\n> \n>   mkdir repo && cd repo\n>   git init\n>   mv .git mygitdir\n>   touch file\n>   git --git-dir=mygitdir add file\n> \n> However, there is a config option \"core.bare\" which indicates that a\n> repository is \"bare\", meaning that it has no work tree (and that is\n> presumably what's happening in your example). So you could use\n> --work-tree=. to override that in your example (though you might just be\n> better off setting config.bare to false).\n> \n> The more probable use case for --work-tree is something like\n> \n>   $ cd /gitdir/mysitegit\n>   $ git --work-tree=/www/mysitedocroot add .\n> \n> i.e., you are in the git dir, so you specify the work tree rather than\n> the other way around. You could even do this:\n> \n>   $ cd /some/other/directory\n>   $ git --git-dir=/gitdir/mysitegit --work-tree=/www/mysitedocroot add .\n> \n> although I'm not sure it's that useful.\n> \n> -Peff\n\nYes, thanks, I was actually following this tutorial:\n\nhttp://www.kernel.org/pub/software/scm/git/docs/cvs-migration.html\n\nWhich is how I ended up with a \"bare\" git dir.  Which actually I think \nI'm ok with, seems to work ok.\n\nFor others with the same questions, here's how I found what work-tree \nmeans last night:\n\nhttp://www.kernel.org/pub/software/scm/git/docs/glossary.html\n\nI think I got there through the git wiki.\n\nAlso- I found out I needed a newish version of git to get the \n--work-tree argument. The CentOS repos have an older version, 1.2.something.\n\nthanks\n"},{"id":"66601","messageId":"20080125215653.GA16694@coredump.intra.peff.net","threadId":"11725","inReplyTo":"479A4C9F.3070200@talkingspider.com","subject":"Re: What's a \"work tree\"?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-25T21:56:54Z","receivedAt":"2008-01-25T21:56:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 25, 2008 at 03:54:55PM -0500, Mike wrote:\n\n> Yes, thanks, I was actually following this tutorial:\n>\n> http://www.kernel.org/pub/software/scm/git/docs/cvs-migration.html\n>\n> Which is how I ended up with a \"bare\" git dir.  Which actually I think  \n> I'm ok with, seems to work ok.\n\nAh, OK. The normal use case would then be to clone that bare repository\n(though you seem to be directly exposing the work tree with the\nwebserver, so you may not want to have the .git directory there -- there\nwas a long-ish thread about that a week or two ago).\n\n> Also- I found out I needed a newish version of git to get the\n> --work-tree argument. The CentOS repos have an older version,\n> 1.2.something.\n\nYes, that is ancient in git terms (in particular, pre-1.5.x has a number\nof interface differences). The work-tree option was added in 1.5.3.\n\n-Peff\n"}]}