【问题标题】:How do I use the --work-tree option with git? I keep getting an error如何在 git 中使用 --work-tree 选项?我不断收到错误
【发布时间】:2012-04-02 12:11:47
【问题描述】:

我有一个正常的仓库,其中有一个工作树和一个与工作树在同一目录中的 .git 文件夹。

我正在尝试使用命令从该位置之外运行 git 命令

git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo pull /some/other/repo master

但我不断收到错误fatal: /usr/libexec/git-core/git-pull cannot be used without a working tree.

我做错了什么?

【问题讨论】:

  • 您当前的工作目录是什么?你用的是什么版本的 Git?
  • 就像这样:所有文件(工作树)都在某个文件夹中,例如/some/repo,并且在这个文件夹中也是一个.git 文件夹/some/repo/.git。我通常会从/some/repo 内部运行 git 命令。我有版本1.7.2.3

标签: git git-push git-pull git-commit


【解决方案1】:

这是早期版本的 Git 中的错误。升级到 1.7.7.2 或更高版本后,此问题应该会消失。

来自the commit that fixed the bug

You can't currently run git-pull or git-rebase from outside
of the work tree, even with GIT_WORK_TREE set, due to an
overeager require_work_tree function. Commit e2eb527
documents this problem and provides the infrastructure for a
fix, but left it to later commits to audit and update
individual scripts.

另见commit e2eb527

【讨论】:

    猜你喜欢
    • 2021-12-25
    • 1970-01-01
    • 2015-06-26
    • 1970-01-01
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-19
    相关资源
    最近更新 更多