Git - 将旧提交与分支最新提交进行比较
Git - compare old commit with branches latest commit
背景:我曾经参与的一个项目改变了它的许可,我想知道我的代码有多少还在最终产品中。
如何使用旧的提交 ID 并将该提交中所做的更改与任何分支最新提交中的当前代码进行比较?
EX:我添加一些代码
int b = j+k;
updateRefs(b,k);
后来此代码更改为
int b = j+m;
updateRefs(b,k);
我如何查看我的代码(例如 updateRefs(b,k);
)还有多少留在分支的最新提交中?
它的边缘会很粗糙,但您可以使用 git blame
并通过 grep
将其管道化。例如,运行 在我的一个项目上(限制为 10 行,因为我是唯一的贡献者):
$ git blame CMakeLists.txt | grep Stephen | head -n 10
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 1) cmake_minimum_required(VERSION 3.9)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 2) cmake_policy(VERSION 3.9)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 3)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 4) project("houseguest"
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 5) LANGUAGES
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 6) CXX
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 7) VERSION
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 8) 0.1.0
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 9) )
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 10)
这将显示最后触摸该行的人,因此它会遗漏一些情况(例如,空格更改或添加到该行的注释)。不过至少应该给你一个粗略的估计。
背景:我曾经参与的一个项目改变了它的许可,我想知道我的代码有多少还在最终产品中。
如何使用旧的提交 ID 并将该提交中所做的更改与任何分支最新提交中的当前代码进行比较?
EX:我添加一些代码
int b = j+k;
updateRefs(b,k);
后来此代码更改为
int b = j+m;
updateRefs(b,k);
我如何查看我的代码(例如 updateRefs(b,k);
)还有多少留在分支的最新提交中?
它的边缘会很粗糙,但您可以使用 git blame
并通过 grep
将其管道化。例如,运行 在我的一个项目上(限制为 10 行,因为我是唯一的贡献者):
$ git blame CMakeLists.txt | grep Stephen | head -n 10
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 1) cmake_minimum_required(VERSION 3.9)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 2) cmake_policy(VERSION 3.9)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 3)
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 4) project("houseguest"
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 5) LANGUAGES
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 6) CXX
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 7) VERSION
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 8) 0.1.0
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 9) )
^72094b3 (Stephen Newell 2018-04-02 19:49:20 -0600 10)
这将显示最后触摸该行的人,因此它会遗漏一些情况(例如,空格更改或添加到该行的注释)。不过至少应该给你一个粗略的估计。