git:是否有一种方法可以显示从修订版中的一组线



如何在某些以前的提交中查看文件的子集。通常我会做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>

最新更新