Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
要将文件与不是当前 HEAD 的某个提交进行比较,我调用git log,记下提交哈希,然后调用git diff <hash> filename.
git log
git diff <hash> filename
有没有办法像这样使用 diff 命令:git diff -<x_commits_back> filename并将文件与x以前版本的版本进行比较?
git diff -<x_commits_back> filename
x
谢谢
是的,您可以使用:
git diff HEAD~X -- filename
酌情更换X。请注意,它遵循合并提交的第一个父级。
X