我如何运行“git status"?只需获取文件名 [英] How can I run "git status" and just get the filenames
问题描述
相对于长相对路径?
推荐答案
git status --porcelain
的输出,旨在易于在脚本中解析,输出完整路径而不是相对路径路径而不管您当前的目录在树中的哪个位置.
The output of git status --porcelain
, designed to be easy to parse in a script, outputs the full paths rather than relative paths regardless of where your current directory is within the tree.
git status --porcelain
输出的每一行都有两个前导字符指示文件的状态(例如它是否未被跟踪、修改、新建、删除等),后跟一个空格,所以如果您只想要 git status
的输出中提到的所有内容的完整路径,您可以这样做:
Each line output by git status --porcelain
has two leading characters indicating the status of the file (e.g. whether it's untracked, modified, new, deleted, etc.) followed by a space, so if you just want the full paths of everything that would be mentioned in the output of git status
you can do:
git status --porcelain | sed s/^...//
这篇关于我如何运行“git status"?只需获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!