Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

how to get only the deleted lines by git diff command?

Is it possible to figure out only the deleted lines of a file by git diff command?

Currently git diff shows both the modified lines and deleted lines shown in the picture.

git diff

question from:https://stackoverflow.com/questions/65889331/how-to-get-only-the-deleted-lines-by-git-diff-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One way to do that using bash would be:

git diff | grep "^-[^-]" , it keeps only the lines starting with a - and do not have a second character - following, intended to avoid printing the files that contain the change.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...