git --git-dir checkout 和 git checkout 之间的区别
difference between git --git-dir checkout and git checkout
git 使用选项 --git-dir
.
结帐的行为不同
命令:
inside_gitdir$ git checkout remote/branch
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-dir
选项有什么区别?
我运行遇到了同样的问题。
如果你这样做似乎有效:git --git-dir=/path/.git --work-tree=/path/ checkout remote/branch
git 使用选项 --git-dir
.
命令:
inside_gitdir$ git checkout remote/branch
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-dir
选项有什么区别?
我运行遇到了同样的问题。
如果你这样做似乎有效:git --git-dir=/path/.git --work-tree=/path/ checkout remote/branch