如何在git中使用--work-tree选项?我一直在收到错误

tru*_*ktr 8 git git-pull git-push git-commit

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

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

git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo pull /some/other/repo master
Run Code Online (Sandbox Code Playgroud)

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

我究竟做错了什么?

Ric*_*sen 9

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

修复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.
Run Code Online (Sandbox Code Playgroud)

另请参见commit e2eb527.