git - 我如何使用 git 的 --work-tree 选项?我不断收到错误

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

我有一个普通的 repo,其中有一个工作树和一个与工作树位于同一目录中的 .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 早期版本中的一个错误。升级到 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 .

关于git - 我如何使用 git 的 --work-tree 选项?我不断收到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9745941/

相关文章:

git - 接受未出现在 VS 代码中的传入更改

git - 为什么在 Visual Studio Code 中执行 git pull 后我有未提交的更改?

git - pull --rebase 后执行 git-hook

git - Git中分支的两次提交之间的变化汇总

git - 测量 git blob 对象大小的正确方法是什么

git - 远程 : Invalid username or password

git - 如何在 Git 中提交后自动推送?

git - 对 github 上的提交感到困惑

git - 如何指定在 git 中使用哪个 SSH key 进行 git push 以便将 gitorious 作为镜像?

linux - 更改 git pull 上的 mtime