git --git-dir checkout 和 git checkout 之间的区别

difference between git --git-dir checkout and git checkout

git 使用选项 --git-dir.

结帐的行为不同

命令:

  1. inside_gitdir$ git checkout remote/branch
  2. outside_gitdir$ git --git-dir=/path/.git checkout remote/branch

此处 命令 1 运行良好并正在检查。但是 命令 2 显示移动文件,如:

error: The following untracked working tree files would be overwritten by checkout:
someFiles

Please move or remove them before you can switch branches.
Aborting

我认为这两个命令都是 运行 的方式相同。但是,

我运行遇到了同样的问题。

如果你这样做似乎有效:git --git-dir=/path/.git --work-tree=/path/ checkout remote/branch