当我运行代码git status /path/to/file
或类似时,我收到上述错误git add "/path/to/file/README"
我已经初始化了/path/to/file
using init
git init /path/to/file
。这似乎工作正常
从 git 手册git status [<options>...] [--] [<pathspec>...]
我明白这意味着我可以添加/path/to/file
(也在这里回答)还是我弄错了?
尝试了这里的答案以及其中的链接(在This question already has an answer here: 下)。
git clone url /path/to/file
工作正常,但git status /path/to/clone/
给出了同样的错误
尝试卸载并重新安装git。git
版本是 2.14.1,在 Ubuntu 17.10 上运行
编辑:如果我cd /path/to/file
运行git status
,它工作正常。
Git 需要知道存储库在哪里,运行git status /path/to/dir
是不够的。当前目录是存储库的(子)目录(即 ),cd /path/to/dir
或者您明确说明存储库的位置:
git --git-dir=/path/to/dir/.git --work-tree=/path/to/dir status README
或者
GIT_DIR=/path/to/dir/.git WORK_TREE=/path/to/dir git status README
似乎cd
是最短和最简单的解决方案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句