1

我在 git repo 中有以下状态:

git status

On branch whatever
Your branch is ahead of 'origin/whatever' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    docs/file1.docx

nothing added to commit but untracked files present (use "git add" to track)

所以我会做一个:

git clean -fdx 

之后 agit status将显示以下内容:

On branch whatever
Your branch is ahead of 'origin/whatever' by 1 commit.
  (use "git push" to publish your local commits)

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:    docs/file1.docx

no changes added to commit (use "git add" and/or "git commit -a")

如果我删除未跟踪的文件,它们怎么会被标记为已删除?

4

1 回答 1

0

我不知道是什么原因造成的,但有时我会进入同样的状态。当它发生时,我通过运行来修复它:

git clean --force

(或),它会git clean -f删除未跟踪的文件,但不会git它们标记为已删除。

有关更多信息,请运行git help clean. 它具有您可能会发现有用的各种其他标志和功能。

于 2018-06-23T20:28:13.237 回答