简体   繁体   English

查看 NUMBER 个本地未提交的文件

[英]View NUMBER of local uncommitted files

I've learned I can use count to find the NUMBER of commits a branch is ahead/behind by, like so:我了解到我可以使用count来查找分支前面/后面的提交次数,如下所示:

git rev-list --count HEAD..@{u}

But is there a way to do so for uncommitted files?但是有没有办法对未提交的文件这样做?

Just found out git status -suno shows how many files have been changed in a really concise way, so I could either count the lines of the output (with echo "$var" | wc -l ) or just put a symbol to denote an arbitrary amount exist, or parse it in a weird way to see the number of deleted/added/modified.刚刚发现git status -suno以非常简洁的方式显示了有多少文件已更改,因此我可以计算 output 的行数(使用echo "$var" | wc -l )或者只是放一个符号来表示存在任意数量,或以奇怪的方式解析它以查看删除/添加/修改的数量。

However, do non "porcelain" and more directly-addressing commands exist to accomplish this task, as parsing commands such as these are seen as bad practice?但是,是否存在非“瓷器”和更直接寻址的命令来完成此任务,因为解析诸如此类的命令被视为不好的做法?

Also, I am using this to add to a git-bash prompt;另外,我正在使用它来添加到 git-bash 提示符; I would normally just type in git status, but would like to have maximum convenience by just showing such.我通常只输入 git 状态,但希望通过显示这样的状态来获得最大的便利。

Ironically, the --porcelain option of git status is meant to be parsed:具有讽刺意味的是, git status--porcelain选项旨在被解析:

 git status --porcelain -suno|wc -l

So while git status is porcelain, git status --porcelain does produce output suitable for consumption by porcelain scripts.因此,虽然git status是瓷器, git status --porcelain确实会产生 output 适合瓷器脚本使用。

I tried to explain said option in " What does the term “porcelain” mean in Git? "我试图在“ Git 中的“瓷器”一词是什么意思?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM