Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in DevOps and Agile by (29.3k points)

Basically, I don't want to see the changed content, just the file names, and line numbers.

1 Answer

0 votes
by (50.2k points)

If you simply want names then you could use:

git diff --names-only

But if there's no built-in option for this, but it is possible to do this in git, with the help of an "external diff" script.

! /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;

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 '^[<>-]'

Reference:  http://schacon.github.io/git/git.html for GIT_EXTERNAL_DIFF.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...