【问题标题】:git subtree split error: You need to run this command from the toplevel of the working treegit subtree split error: 您需要从工作树的顶层运行此命令
【发布时间】:2020-02-29 07:11:48
【问题描述】:

我在 /srv/git/mysite.git 中有一个 git 存储库。

工作目录设置为

/srv/www/mysite

在 git /srv/git/mysite.git/config 中:

[core] repositoryformatversion = 0
filemode = false
bare = false
worktree = /srv/www/mysite

[receive] denyCurrentBranch = updateInstead

我想用子树拆分目录内容:

/srv/www/mysite/mysubsite

分支mysubsite。

当我执行时:

cd /srv/git/mysite.git
git subtree split --prefix=mysubsite -b mysubsite

我得到错误

您需要从工作树的顶层运行此命令。

这个帖子似乎有关于我的问题的相关信息: http://git.661346.n2.nabble.com/git-users-Problem-using-detached-worktrees-with-commands-implemented-in-scripts-td7597786.html

我尝试了以下方法:

export GIT_WORK_TREE=/srv/www/mysite

export GIT_DIR=/srv/git/mysite.git

cd /srv/www/mysite

git subtree split --prefix=mysubsite -b mysubsite

我又报错了:

您需要从工作树的顶层运行此命令。

我该如何解决这个问题?

【问题讨论】:

    标签: git split git-subtree


    【解决方案1】:

    对我有用,export GIT_DIR 就足够了。

    $ git --version 
    git version 2.11.0
    

    这也有效:

    $ cd /srv/www/mysite
    $ git --git-dir=/srv/git/mysite.git subtree split --prefix=mysubsite -b mysubsite
    

    【讨论】:

    • --git-dir=/srv/git/mysite.git 选项使它成功运行!非常感谢!
    猜你喜欢
    • 2013-09-27
    • 2020-03-23
    • 2014-12-05
    • 2022-07-07
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 2012-09-10
    • 2020-07-22
    相关资源
    最近更新 更多