threads / discuss / 26414

[idea] separate .git dir and the working tree

Subject: [idea] separate .git dir and the working tree

## tl;dr

12 messages between Feb 5, 2011 and May 23, 2011.

replies: 11people: 7as markdown or json

redstun· Feb 5, 2011, 02:53 UTC · lore
First please shout if this is a known feature :-)

I think separating the .git directory from its working tree could increase the safety of the data to one more level higher.

We might have a git variable set to specify (a shared place) where to put the .git directories (or the data inside it), then use "/path/to/working/tree" as (or the seed to calculate) a hash key to map from the (.git directory in the) shared place to the working tree directory.

Or we may have just a few data (that can be re-created) stored in the .git directory along with the working tree, and most of the revision history stored in the shared place.

Mike Gant· Feb 5, 2011, 03:23 UTC · re: redstun · lore

Re: [idea] separate .git dir and the working tree

On Sat, Feb 05, 2011 at 10:53:58AM +0800, redstun wrote:
Show 14 quoted lines
> First please shout if this is a known feature :-)
> 
> I think separating the .git directory from its working tree could
> increase the safety of the data to one more level higher.
> 
> We might have a git variable set to specify (a shared place) where to
> put the .git directories (or the data inside it), then use
> "/path/to/working/tree" as (or the seed to calculate) a hash key to
> map from the (.git directory in the) shared place to the working tree
> directory.
> 
> Or we may have just a few data (that can be re-created) stored in the
> .git directory along with the working tree, and most of the revision
> history stored in the shared place.

GIT_DIR and GIT_WORK_TREE might be what you are looking for. Explanation of usage in 'man git'

HTH Mike

> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Nieder· Feb 5, 2011, 13:27 UTC · re: Mike Gant · lore

Re: [idea] separate .git dir and the working tree

(restoring cc list; please do not cull cc's)
Mike Gant wrote:
> On Sat, Feb 05, 2011 at 10:53:58AM +0800, redstun wrote:
>> I think separating the .git directory from its working tree could
>> increase the safety of the data to one more level higher.
[...]
> GIT_DIR and GIT_WORK_TREE might be what you are looking for. Explanation
> of usage in 'man git'
The .git directory is allowed to be a symlink.  Or a file like so
	gitdir: /path/to/git/repo

for symlink-challenged operating systems. See gitrepository-layout(7) for details.

Cheers, Jonathan

redstun· Feb 5, 2011, 14:24 UTC · re: Jonathan Nieder · lore

Re: [idea] separate .git dir and the working tree

Making .git a symbol link is nice.

Regarding the GIT_DIR variable, looks like it needs to be paired with the GIT_WORK_TREE variable, does this mean that I can only have one local git repository?

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.
Thanks
On Sat, Feb 5, 2011 at 9:27 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 21 quoted lines
> (restoring cc list; please do not cull cc's)
>
> Mike Gant wrote:
>> On Sat, Feb 05, 2011 at 10:53:58AM +0800, redstun wrote:
>
>>> I think separating the .git directory from its working tree could
>>> increase the safety of the data to one more level higher.
> [...]
>> GIT_DIR and GIT_WORK_TREE might be what you are looking for. Explanation
>> of usage in 'man git'
>
> The .git directory is allowed to be a symlink.  Or a file like so
>
>        gitdir: /path/to/git/repo
>
> for symlink-challenged operating systems.  See gitrepository-layout(7)
> for details.
>
> Cheers,
> Jonathan
>
Jonathan Nieder· Feb 5, 2011, 18:04 UTC · re: redstun · lore

Re: [idea] separate .git dir and the working tree

redstun wrote:
Show 9 quoted lines
> 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
Mike Gant· Feb 6, 2011, 00:20 UTC · re: Jonathan Nieder · lore

Re: [idea] separate .git dir and the working tree

On Sat, Feb 05, 2011 at 07:27:08AM -0600, Jonathan Nieder wrote:
> (restoring cc list; please do not cull cc's)

My apologies, but I didn't see a cc list in the original. Please explain.

-Mike
Mike Gant· Feb 6, 2011, 00:40 UTC · re: Mike Gant · lore

Re: [idea] separate .git dir and the working tree

On Sat, Feb 05, 2011 at 05:20:09PM -0700, Mike Gant wrote:
Show 7 quoted lines
> On Sat, Feb 05, 2011 at 07:27:08AM -0600, Jonathan Nieder wrote:
> > (restoring cc list; please do not cull cc's)
> 
> My apologies, but I didn't see a cc list in the original. Please
> explain.
> 
> -Mike
Never mind, I think I understand.

So does anyone use Mutt? And do they know a recipe to move the sender address to the cc list? If not, I'll figure it out.

Thanks, -Mike

Jared Hance· Feb 6, 2011, 01:00 UTC · re: Mike Gant · lore

Re: [idea] separate .git dir and the working tree

On Sat, 2011-02-05 at 17:40 -0700, Mike Gant wrote:
Show 20 quoted lines
> On Sat, Feb 05, 2011 at 05:20:09PM -0700, Mike Gant wrote:
> > On Sat, Feb 05, 2011 at 07:27:08AM -0600, Jonathan Nieder wrote:
> > > (restoring cc list; please do not cull cc's)
> > 
> > My apologies, but I didn't see a cc list in the original. Please
> > explain.
> > 
> > -Mike
> 
> Never mind, I think I understand.
> 
> So does anyone use Mutt? And do they know a recipe to move the sender
> address to the cc list? If not, I'll figure it out.
> 
> Thanks,
> -Mike
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
When I used Mutt, if I remember correctly, L did the job (list reply).
Konstantin Khomoutov· Feb 6, 2011, 10:49 UTC · re: Jared Hance · lore

Re: [idea] separate .git dir and the working tree

On Sat, Feb 05, 2011 at 08:00:15PM -0500, Jared Hance wrote:
Show 6 quoted lines
> > > My apologies, but I didn't see a cc list in the original. Please
> > > explain.
> > Never mind, I think I understand.
> > So does anyone use Mutt? And do they know a recipe to move the sender
> > address to the cc list? If not, I'll figure it out.
> When I used Mutt, if I remember correctly, L did the job (list reply).

Also "g" is "group reply" -- it simply replies to all e-mails mentioned in the mail which is being replied to.

Nicolas Sebrecht· Feb 6, 2011, 10:55 UTC · re: Mike Gant · lore

[idea] Re: separate .git dir and the working tree

The 05/02/11, Mike Gant wrote:
> So does anyone use Mutt? And do they know a recipe to move the sender
> address to the cc list? If not, I'll figure it out.
g (group answer).
-- 
Nicolas Sebrecht
Mike Gant· Feb 7, 2011, 04:57 UTC · re: Nicolas Sebrecht · lore

Re: [idea] Re: separate .git dir and the working tree

On Sun, Feb 06, 2011 at 11:55:10AM +0100, Nicolas Sebrecht wrote:
Show 7 quoted lines
> The 05/02/11, Mike Gant wrote:
> 
> > So does anyone use Mutt? And do they know a recipe to move the sender
> > address to the cc list? If not, I'll figure it out.
> 
> g (group answer).
> 

Thanks. I knew about L (list reply) and g (group reply). L only replies to the list address, git@vger.kernel.org, in this case. Certainly, g is the closest behavior as long as it is acceptable to have the sender name in the To: header along with the list address (as in this response).

On the other hand, if it is only acceptable to have the list address in the To: header and all others in the cc list then I don't know of any command to do that.

-Mike
Michael Witten· May 23, 2011, 14:40 UTC · re: Mike Gant · lore

Re: [idea] separate .git dir and the working tree

On Sun, Feb 6, 2011 at 00:40, Mike Gant <mike@gantsfort.com> wrote:
> So does anyone use Mutt? And do they know a recipe to move the sender
> address to the cc list? If not, I'll figure it out.

Your `To:' header should list the sender (usually what's listed in the `From:' header); the `Cc:' header should list everything else (including the mailing list(s) in question).

← back to recent threads