setting the work-tree of each bare repo

后端 未结 3 1214
醉梦人生
醉梦人生 2020-12-29 12:54

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=/va         


        
3条回答
  •  清歌不尽
    2020-12-29 13:37

    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
    

提交回复
热议问题