设置每个裸回购的工作树 [英] setting the work-tree of each bare repo

查看:84
本文介绍了设置每个裸回购的工作树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  cd barerepo $ b $正如您在下面看到的,我必须设置裸回购的工作树: b git status 
fatal:这个操作必须在工作树中运行

git --work-tree = / var / www / mywork / status
#在分支master上$



如何设置工作树回购,以便我不必每次都指定它?



我尝试用此修改 barerepo / config ,但它不起作用。

  [core] 
repositoryformatversion = 0
filemode = true
bare = true
worktree = / var / www / mywork


解决方案如果没有工作树,那么git将打印出致命的:core.bare和core.worktree没有意义的错误信息。因此,您需要在回购的配置文件中设置 bare = false

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

但是,如果以前不存在barerepo,则应该使用此命令相反:

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

这个命令还会创建一个 .git 在工作树中指向git目录的文件:

  gitdir:/ home / user / barerepo 


As you can see below I have to set the work-tree of a bare 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 do I set the work-tree for that repo so that I don't have to specify it everytime?

I tried modifying barerepo/config with this but it doesn't work.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
    worktree = /var/www/mywork

解决方案

Bare repos are not supposed to have a work tree, so git prints the "fatal: core.bare and core.worktree do not make sense" error message. Therefore, you need to set bare = false in the repo's config 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 previously exist, you should use this command instead:

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

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

gitdir: /home/user/barerepo

这篇关于设置每个裸回购的工作树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆