我用谷歌搜索了这个问题以及很多文章,展示了如何查看过去几天或最后一次提交的更改。
我真正想要的是查看文件的最后更改,无论何时以及哪个提交。
假设我有 FileA 和 FileB
提交 1:更改了 FileA 和 FileB
提交2~99:更改了FileB
我想查看的是对 FileA 的最后一次更改是什么,而不知道哪个提交影响了 FileA。
当我 git pull 共享项目时,这特别有用(至少对我来说),我看到大量提交更改的文件列表,我感兴趣对某些文件进行了哪些更改,但这有点难做。
我会简单地尝试
git log -1 -p -- path/to/your/file
Run Code Online (Sandbox Code Playgroud)
就像 git help 所说:
-<n>
Limits the number of commits to show. Note that this is a commit
limiting option.
[--] <path>...
Show only commits that are enough to explain how the files that
match the specified paths came to be. See "History Simplification"
below for details and other simplification modes.
Run Code Online (Sandbox Code Playgroud)