Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Staged Stats(暂存行数/注释占比)New to Visual Studio Code? Get it now.
Git Staged Stats(暂存行数/注释占比)

Git Staged Stats(暂存行数/注释占比)

shyechou

|
2 installs
| (0) | Free
Show staged added lines and comment ratio in the status bar. 状态栏显示暂存区新增行数和注释占比。
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Staged Stats(暂存行数/注释占比)

提交前先看一眼:这次 git add 了多少行,其中注释占多少。

Show staged added lines and comment ratio in the status bar.

git add 后状态栏出现暂存行数和注释占比

安装后,左下角会显示例如:暂存 +128 行 · 注释 23%。注释占比达到 40%(可改)时,状态栏会变成黄色。

状态栏:暂存 +128 行 · 注释 23%

怎么用

  1. 在 VS Code / Cursor 扩展商店搜 Git Staged Stats
  2. 打开任意 Git 仓库
  3. git add 一些文件
  4. 看左下角状态栏

点击状态栏可打开按文件明细。

命令面板:

  • Git Staged Stats: 显示明细
  • Git Staged Stats: 刷新

和 Git Line Diff Counter 的差别

Git Line Diff Counter 会显示暂存/未暂存的 +N/-M 行数。

Git Staged Stats 额外回答另一个问题:这次暂存里,有多少是注释。

Git Line Diff Counter Git Staged Stats
暂存行数 有 有
未暂存行数 有 无(只看暂存区)
注释占比 无 有
注释过高警告 无 状态栏变黄

适合在提交前检查「是不是注释注水了」,而不是统计整个仓库有多少行代码。

统计规则

  • 只看暂存区,不看未暂存改动
  • +N 行 是 unified diff 里的非空 + 行(新增,以及修改后的新行)
  • 空行不计入行数和占比
  • 行尾注释仍算代码,例如 foo(); // note
  • Markdown、lock 文件、图片等会跳过
  • 字符串里的 // 不会当成注释

设置

  • gitStagedStats.warnCommentPercent:注释占比达到该百分比时使用警告底色(默认 40)
  • gitStagedStats.hideWhenEmpty:暂存区为空时隐藏状态栏(默认 false)
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft