如何在某些以前的提交中查看文件的子集。通常我会做git show HEAD:path/to/file
,但是如果我只对我想说的代码的特定领域感兴趣,例如git show HEAD:path/to/someFile 33-47
仅显示这些行的当前头处someFile
的状态。
git show HEAD:path/to/someFile | tail -n +33 | head -n $((47-33+1))
@elpiekay提供了一个清洁的解决方案:
git show HEAD:path/to/someFile | sed -n 33,47p
git blame <revision> -L 33,47 <path>