是否可以只对修改过的文件进行“git status”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10018533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
is it possible to `git status` only modified files?
提问by chrisjlee
Is it possible to git status
and show only modified files?
是否可以git status
只显示修改过的文件?
The problem is i have too many staged files that i don't want to commit or gitignore at the moment and i can't scroll up. I have a scrollback limit set on Ubuntu.
问题是我有太多暂存文件,我现在不想提交或 gitignore,我无法向上滚动。我在 Ubuntu 上设置了回滚限制。
回答by Lily Ballard
You can't do this with git status
, but you could use git ls-files -m
to show all modified files.
你不能用 来做到这一点git status
,但你可以用git ls-files -m
来显示所有修改过的文件。
回答by TomNysetvold
It looks like git status -uno
will show you only files that git is tracking, without showing anything else in the directory. Not exactly what you asked for, but perhaps accomplishes the same thing (getting a readable-length list of files that git tracks).
看起来git status -uno
只会显示 git 正在跟踪的文件,而不显示目录中的任何其他内容。不完全是你所要求的,但也许完成了同样的事情(获得 git 跟踪的可读长度的文件列表)。
回答by Carl B?ckstr?m
git status -s | awk '{if ( == "M") print }'
回答by Lance
For modified files:
对于修改过的文件:
git status | grep modified:
回答by ZeroGraviti
git diff --name-only --diff-filter=M
git diff --name-only --diff-filter=M
回答by mpelzsherman
git diff --name-only
works too.
git diff --name-only
也有效。
回答by Tectrendz
I was looking for the same info and found following gives modified files:
我正在寻找相同的信息,发现以下提供了修改后的文件:
git status -uno
回答by Karthik
You can use
您可以使用
$ git status -uno
to list only modified files.
只列出修改过的文件。
回答by BillFienberg
The problem is i have too many staged files that i don't want to commit or gitignore at the moment and i can't scroll up.
问题是我有太多暂存文件,我现在不想提交或 gitignore,我无法向上滚动。
While this may not directly answer the question of listing only modified files, it may help limit the number of files that are listed.
虽然这可能无法直接回答仅列出修改过的文件的问题,但它可能有助于限制列出的文件数量。
You can pass a path to git status
to limit the output to a specific folder in the repo.
您可以传递路径以git status
将输出限制到存储库中的特定文件夹。
For example:
例如:
git status app
git status spec
git status src/components
回答by briggySmalls
To list the modified files use:
要列出修改过的文件,请使用:
git ls-files -m
If you want just the basename (no path) then you can pipe each result to the basename command using xargs, line by line:
如果您只需要 basename(无路径),那么您可以使用 xargs 逐行将每个结果通过管道传输到 basename 命令:
git ls-files -m | xargs -L 1 basename