在做git diff --stat一些文件时列出了来自存储库库的完整路径,但有些文件列为:
.../short/path/to/filename.
Run Code Online (Sandbox Code Playgroud)
这是路径开始,...只显示短路径.
我想git diff列出所有文件的完整文件路径,以便脚本轻松处理.有什么方法可以让我git diff总是显示完整的路径
tor*_*rek 98
该git diff命令采用以下可选值--stat:
--stat[=<width>[,<name-width>[,<count>]]]
Generate a diffstat. You can override the default output width for
80-column terminal by --stat=<width>. The width of the filename
part can be controlled by giving another width to it separated by a
comma. By giving a third parameter <count>, you can limit the
output to the first <count> lines, followed by ... if there are
more.
These parameters can also be set individually with
--stat-width=<width>, --stat-name-width=<name-width> and
--stat-count=<count>.
Run Code Online (Sandbox Code Playgroud)
(对于脚本,你可能想git diff-tree直接使用,因为它更像是一个"管道"命令,虽然我怀疑你会很好.请注意你--stat在使用时需要相同的额外文本git diff-tree.使用git diff"瓷器" 之间的本质区别"前端和git diff-tree管道命令,是git diff查找已配置的选项,diff.renames以决定是否进行重命名检测.好吧,如果您将提交与索引进行比较git diff,git diff-index那么加上前端将完成相同的操作例如.换句话说,git diff 读取您的配置并自动调用正确的管道.)
cmb*_*ley 17
对于脚本处理,最好使用以下方法之一:
# list just the file names
git diff --name-only
path/to/modified/file
path/to/renamed/file
# list the names and change statuses:
git diff --name-status
M path/to/modified/file
R100 path/to/existing/file path/to/renamed/file
# list a diffstat-like output (+ed lines, -ed lines, file name):
git diff --numstat
1 0 path/to/modified/file
0 0 path/to/{existing => renamed}/file
Run Code Online (Sandbox Code Playgroud)
当与作为字段终止符的-z选项结合使用时,这些对于强大的脚本处理变得更加方便NUL.
Joh*_*lor 15
对于Bash用户,您可以使用该$COLUMNS变量自动填充可用的终端宽度:
git diff --stat=$COLUMNS
Run Code Online (Sandbox Code Playgroud)
很长的路径名称可能仍会被截断; 在这种情况下,您可以使用缩小+++/---部分的宽度--stat-graph-width,例如,这会将其限制为终端宽度的1/5:
git show --stat=$COLUMNS --stat-graph-width=$(($COLUMNS/5))
Run Code Online (Sandbox Code Playgroud)
对于更通用的解决方案,您可以使用输出tput cols来确定终端宽度.
| 归档时间: |
|
| 查看次数: |
25044 次 |
| 最近记录: |