git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Mike <fromlists@talkingspider.com>
Cc: git@vger.kernel.org
Subject: Re: What's a "work tree"?
Date: Fri, 25 Jan 2008 01:14:21 -0500	[thread overview]
Message-ID: <20080125061421.GC21973@coredump.intra.peff.net> (raw)
In-Reply-To: <4798E26D.3040707@talkingspider.com>

On Thu, Jan 24, 2008 at 02:09:33PM -0500, Mike wrote:

> I'm trying to figure out what a "work tree" is.  as in --work-tree. This 
> is a new command right, the tutorials I've read don't have it. The man 
> page has the syntax but I don't know what it's for.

The work tree is the place where your checked out files reside. E.g.,
in an ordinary repo (made with "git init" or "git clone") everything
that isn't in the .git directory.

> $ cd /www/mysitedocroot
> $ git --git-dir /gitdir/mysitegit/ add .
> fatal: add must be run in a work tree

You are using --git-dir to point to a repository directory that isn't
".git". That's OK, and it will generally assume that your current
directory is the work tree. E.g., this works:

  mkdir repo && cd repo
  git init
  mv .git mygitdir
  touch file
  git --git-dir=mygitdir add file

However, there is a config option "core.bare" which indicates that a
repository is "bare", meaning that it has no work tree (and that is
presumably what's happening in your example). So you could use
--work-tree=. to override that in your example (though you might just be
better off setting config.bare to false).

The more probable use case for --work-tree is something like

  $ cd /gitdir/mysitegit
  $ git --work-tree=/www/mysitedocroot add .

i.e., you are in the git dir, so you specify the work tree rather than
the other way around. You could even do this:

  $ cd /some/other/directory
  $ git --git-dir=/gitdir/mysitegit --work-tree=/www/mysitedocroot add .

although I'm not sure it's that useful.

-Peff

  reply	other threads:[~2008-01-25  6:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-24 19:09 What's a "work tree"? Mike
2008-01-25  6:14 ` Jeff King [this message]
2008-01-25 20:54   ` Mike
2008-01-25 21:56     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080125061421.GC21973@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=fromlists@talkingspider.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).