使用git diff,我如何获得添加和修改的行号? [英] Using git diff, how can I get added and modified lines numbers?
本文介绍了使用git diff,我如何获得添加和修改的行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个文本文件
alex
bob
矩阵
将会删除了
git repo
并且我已将其更新为
alex
新行在这里
另一个新行
bob
矩阵
git
在这里,我添加了行号(2,3)和更新的行号(6) b
$ b
如何使用git diff或其他任何git命令获取这些行号信息?
解决方案
git diff --stat
会显示您提交的内容,这是您所指的内容。
git diff --stat
准确显示您可以使用的行号已被更改
git blame -p< file> ; | grep还没有提交
并且该行被更改为最后一个数字,结果。虽然不是一个干净的解决方案:(
Assuming I have a text file
alex
bob
matrix
will be removed
git repo
and I have updated it to be
alex
new line here
another new line
bob
matrix
git
Here, I have added lines number (2,3) and updated line number (6)
How can I get these line numbers info using git diff or any other git command?
解决方案
git diff --stat
will show you the output you get when committing stuff which is the one you are referring to I guess.
git diff --stat
For showing exactly the line numbers that has been changed you can use
git blame -p <file> | grep "Not Committed Yet"
And the line changed will be the last number before the ending parenthesis in the result. Not a clean solution though :(
这篇关于使用git diff,我如何获得添加和修改的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文