Git:有没有办法显示修订版的一部分行?

时间:2017-09-25 21:24:07

标签: git

如何在之前的某个提交中查看文件中的行子集。通常我做 {'ip0': ['1.1.1.1'], 'ip2': ['2.2.2.2', '3.3.3.3'], 'ip3': ['4.4.4.4', '5.5.5.5', '6.6.6.6']} 但是如果我只对代码的某个特定区域感兴趣,我希望能够说,例如git show HEAD:path/to/file,它会显示git show HEAD:path/to/someFile 33-47的状态。仅适用于那些线路的当前HEAD。

2 个答案:

答案 0 :(得分:3)

git show HEAD:path/to/someFile | tail -n +33 | head -n $((47-33+1))

@ElpieKay使用sed:

提供更清洁的解决方案
git show HEAD:path/to/someFile | sed -n 33,47p

答案 1 :(得分:2)

git blame <revision> -L 33,47 <path>
相关问题