【问题标题】:untracked files未跟踪的文件
【发布时间】:2020-03-21 10:10:42
【问题描述】:

~ master ?49 ❯ git status
> warning: could not open directory '.Trash/': Operation not permitted
On branch master

No commits yet

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

~ master ?49 ❯
> nothing added to commit but untracked files present (use "git add" to track)

?49 是什么意思?是不是跟 Git 有关系?

另外,当我输入 git status 时,它会列出我所有的文件并给我这个:

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

【问题讨论】:

  • @maievS :您询问提示中字符的含义,但您没有发布如何定义提示字符串!
  • @maievS :在git status 上,git 总是列出您的 git 目录中尚未放入 git 的文件。你必须下定决心:要么将文件添加到仓库中,要么将它们放入 .gitignore
  • 这就是为什么我不喜欢使用oh-my-zsh。它提供了大量用户不一定知道的定制,因此很难回答诸如“为什么我的 shell 会这样?”这样的问题。 (作为自定义创意的来源,我喜欢oh-my-zsh。)
  • 我怀疑 49 是指未跟踪文件的数量,git status(但不是zsh)会忽略。

标签: git zsh oh-my-zsh git-untracked


【解决方案1】:

提示符中的?49 表示当前 Git 存储库中有 49 个未跟踪文件。

来自Powerlevel10k FAQ

问:Git 状态中不同的符号是什么意思?

当使用 LeanClassicRainbow 样式时,Git 状态可能如下所示:

feature:master ⇣42⇡42 *42 merge ~42 +42 !42 ?42

传说:

| Symbol  | Meaning                                                           | Source                                               |
| --------| ------------------------------------------------------------------| ---------------------------------------------------- |
| feature | current branch; replaced with #tag or @commit if not on a branch  | git status                                           |
| master  | remote tracking branch; only shown if different from local branch | git rev-parse --abbrev-ref --symbolic-full-name @{u} |
| ⇣42     | this many commits behind the remote                               | git status                                           |
| ⇡42     | this many commits ahead of the remote                             | git status                                           |
| *42     | this many stashes                                                 | git stash list                                       |
| merge   | repository state                                                  | git status                                           |
| ~42     | this many merge conflicts                                         | git status                                           |
| +42     | this many staged changes                                          | git status                                           |
| !42     | this many unstaged changes                                        | git status                                           |
| ?42     | this many untracked files                                         | git status                                           |

另见:How do I change the format of Git status?

如果您在主目录的根目录创建了一个 Git 存储库来存储点文件,您可能希望忽略其中未跟踪的文件。您可以通过执行以下命令来实现:

git -C ~ config status.showuntrackedfiles no

这会有几个效果:

  • 关于.Trash 权限的警告将消失。
  • git status 会更快。
  • git status 不会列出 49 个未跟踪的文件。
  • ?49 将从您的提示中消失。

您可以使用以下命令撤消上述命令:

git -C ~ config --unset status.showuntrackedfiles

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-15
    • 2018-07-21
    • 1970-01-01
    • 2012-03-28
    • 2017-12-30
    相关资源
    最近更新 更多