1

目前我在变更集 1 有 1 个文件:

爪哇

statements_0
statements_1
statements_2

在重构期间,我将 statements_1 移动到 B.java 中。以便:

A.java:

statements_0
statements_2

B.java

statements_1

有没有办法维护 statements_1 的更改历史?

这意味着,在未来的提交中,我总是可以在 statements_1 上追溯(并进行差异)直到变更集 1。

4

1 回答 1

1

You can try a

git log --follow -L1,1:B.java

(The -L option of git log is from git1.8.4 and is illustrated here)

You can also use git blame, as suggested in this answer, except you would need to add the -C10 option to detect moves between files.

('10' because the default bound for number of alphanumeric characters that Git must detect as moving/copying between files for it to associate those lines with the parent commit is 40. And if 'statements_1' is actually 'statements_1', it would be too small to be detected).

git rblame -M -n -L1,1 -C B.java
于 2013-11-11T07:54:45.203 回答