这个问题需要“行号”。如果您不关心输出中的行号,请使用 .
基本上,我不想看到更改的内容,只想看到文件名和行号。
发布于 2012-03-25 05:32:38
注意:如果您只是查找已更改文件的名称编号(对于已更改的行,不使用行号),请参阅another answer here。
这方面没有内置的选项(我也不认为它有多大用处),但在Git中,借助一个“外部比较”脚本就可以做到这一点。
这里有一个非常糟糕的例子;它将由你来按照你想要的方式来修复输出。
#! /bin/sh
#
# run this with:
# GIT_EXTERNAL_DIFF=<name of script> git diff ...
#
case $# in
1) "unmerged file $@, can't show you line numbers"; exit 1;;
7) ;;
*) echo "I don't know what to do, help!"; exit 1;;
esac
path=$1
old_file=$2
old_hex=$3
old_mode=$4
new_file=$5
new_hex=$6
new_mode=$7
printf '%s: ' $path
diff $old_file $new_file | grep -v '^[<>-]'
有关“外部比较”的详细信息,请参阅Git manual page上对GIT_EXTERNAL_DIFF
的描述(在第700行附近,非常接近末尾)。
发布于 2012-12-13 08:50:53
使用:
git diff --name-only
勇往直前,与众不同吧!
发布于 2012-03-24 09:29:56
更改的行数中的行号还是包含更改的实际行号?如果您想要更改的行数,请使用git diff --stat
。这将显示如下所示的内容:
[me@somehost:~/newsite:master]> git diff --stat
whatever/views/gallery.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
没有选项来获取更改本身的行号。
https://stackoverflow.com/questions/9848347
复制相似问题