我希望这很简单,我只是奇怪地配置了 git,但我认为这不是预期的行为。
我创建了一个简单的 git repo
> mkdir tmp
> cd tmp
> touch this
> mkdir that
> touch that/what
> git init
Initialized empty Git repository in /home/.../tmp/.git/
> git add this that
> git commit -a -m "initial commit"
[master (root-commit) 679f2ae] initial commit
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 that/what
create mode 100644 this
然后我在新创建的 git repo 中做一个状态
> git status
# On branch master
nothing to commit, working directory clean
正如预期的那样,无需提交任何内容。但是,当我 cd 进入目录“那个”并执行状态时,我得到以下信息:
> cd that
> git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: that/what
# deleted: this
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# what
no changes added to commit (use "git add" and/or "git commit -a")
我的问题是当我当前的工作目录不是 repo 的根目录时,为什么 git 认为所有内容都被删除/未跟踪。我不认为这是预期的行为。