Installing the working tree of each bare repo

As you can see below, I have to install the tree tree with an open repo:

cd barerepo git status fatal: This operation must be run in a work tree git --work-tree=/var/www/mywork/ status # On branch master nothing to commit (working directory clean) 

How to set up a working tree for this repo so I don't have to specify it every time?

I tried modifying barerepo/config this, but it does not work.

 [core] repositoryformatversion = 0 filemode = true bare = true worktree = /var/www/mywork 
+8
source share
3 answers

Bare repositories should not have a working tree, so git displays the error message "fatal: core.bare and core.worktree does not make sense." Therefore, you need to set bare = false in the repo configuration file.

 user@host :~$ cd barerepo user@host :~/barerepo$ git config --bool core.bare false user@host :~/barerepo$ git config --path core.worktree /var/www/mywork 

However, if barerepo did not exist before, you should use this command:

 git init --separate-git-dir=. /var/www/mywork 

This command will also create a .git file in the work tree, pointing to the git directory:

 gitdir: /home/user/barerepo 
+12
source

Please note that the proposed solution (2012, pre Git 2.5, which will be released in July 2015) will not work directly with the git config command.
He will continue to die with:

 fatal: core.bare and core.worktree do not make sense. 

Here is what Git 2.5 will be (July 2015):

See commit fada767 (May 29, 2015) by Jeff King ( peff ) .
(merger of Junio โ€‹โ€‹C Hamano - gitster - at commit 103b6f9 , June 16, 2015)

setup_git_directory : delay core.bare / core.worktree errors

If both core.bare and core.worktree , we complain about the dummy config and death.
Dying is good, because it avoids the execution of commands and causing damage to a potentially incorrect setup.
But dying is bad, because this means that teams that donโ€™t even care about the work tree cannot work.
This can make it difficult to recover :

  [setup] $ git config core.bare true $ git config core.worktree /some/path [OK, expected.] $ git status fatal: core.bare and core.worktree do not make sense [Hrm...] $ git config --unset core.worktree fatal: core.bare and core.worktree do not make sense [Nope...] $ git config --edit fatal: core.bare and core.worktree do not make sense [Gaaah.] $ git help config fatal: core.bare and core.worktree do not make sense 

Instead, issue a dummy configuration warning when we notice this (i.e. for all commands), but only die when the team tries to use the work tree (by calling setup_work_tree).

So now we get:

 $ git status warning: core.bare and core.worktree do not make sense fatal: unable to set up work tree using invalid config $ git config --unset core.worktree warning: core.bare and core.worktree do not make sense 
+2
source

Please note that the question and answers relate to 2012, but starting with git 2.5, even with empty storage, you can create separate working trees with:

 $ git worktree add /var/www/mywork/ master $ git worktree add /var/www/workdev/ devel 

See git-worktree (1) .

This will not change core.worktree , but will create a worktrees directory in your git repository.

You might want to change the extensions.worktreeConfig configuration option to true if you do not want all working trees and an empty repository to use the same configuration.

0
source

All Articles