git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: redstun <redstun@gmail.com>
Cc: git@vger.kernel.org, Mike Gant <mike@gantsfort.com>
Subject: Re: [idea] separate .git dir and the working tree
Date: Sat, 5 Feb 2011 12:04:25 -0600	[thread overview]
Message-ID: <20110205180425.GA18961@elie> (raw)
In-Reply-To: <AANLkTinYMuXSvKjgtpSCbJPuo=PHDGR_OgOkwtV4Azmz@mail.gmail.com>

redstun wrote:

> what I wanted is, I may have multiple git working tree in my $HOME, like:
> $HOME/proj1
> $HOME/proj2,
> 
> I then wanted their .git directories respectively located at
> /safe/disk/.git_proj1
> /safe/disk/.git_proj2
> 
> How can I get this? I tried to read the doc but didn't have much luck.

By making .git in $HOME/proj1 a symlink to /safe/disk/.git_proj1 and
making $HOME/proj2/.git a symlink to /safe/disk/.git_proj2.
GIT_DIR should be left unset for this to work.

The GIT_DIR variable is for more complicated use cases in which you
do not want a .git directory, file, or symlink in the worktree at all.

One uses it as follows:

	GIT_DIR=/somewhere/else/.git git <command> ...

The top level of the work tree is inferred to be the current working
directory and git metadata is taken from somewhere else.

Sometimes a person does not only want to work in the top level of the
working tree.  To tell git where the top level is, use the
GIT_WORK_TREE variable:

	(
		GIT_DIR=/somewhere/else/.git; export GIT_DIR
		GIT_WORK_TREE=$(pwd); export GIT_WORK_TREE

		cd sub/directory
		git <command>...

		cd ../other/directory
		git <other command>...
	)

These are not variables for your .profile, since as you mentioned, a
person typically will work with one git repo and worktree sometimes,
another git repo and work tree another time.

Hope that helps,
Jonathan

Side note: I don't think you mentioned wanting it, but for reference,
there is a nice tool for sharing objects between multiple worktrees in
contrib/worktree.  It comes with some sharp edges, as described in [1].

[1] http://thread.gmane.org/gmane.comp.version-control.git/150559

  reply	other threads:[~2011-02-05 18:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-05  2:53 [idea] separate .git dir and the working tree redstun
2011-02-05  3:23 ` Mike Gant
2011-02-05 13:27   ` Jonathan Nieder
2011-02-05 14:24     ` redstun
2011-02-05 18:04       ` Jonathan Nieder [this message]
2011-02-06  0:20     ` Mike Gant
2011-02-06  0:40       ` Mike Gant
2011-02-06  1:00         ` Jared Hance
2011-02-06 10:49           ` Konstantin Khomoutov
2011-02-06 10:55         ` [idea] " Nicolas Sebrecht
2011-02-07  4:57           ` Mike Gant
2011-05-23 14:40         ` [idea] " Michael Witten

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=20110205180425.GA18961@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mike@gantsfort.com \
    --cc=redstun@gmail.com \
    /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).