如何在 Git 中查看文件历史记录?

2024-02-26

通过 Subversion 我可以使用乌龟SVN https://en.wikipedia.org/wiki/TortoiseSVN查看文件的历史记录/日志。

我怎样才能用 Git 做到这一点?

我只是寻找特定文件的历史记录,然后比较不同版本的能力。


Use git log http://git-scm.com/docs/git-log查看提交历史记录。每个提交都有一个关联的修订说明符,它是一个哈希键(例如14b8d0982044b0c49f7a855e396206ee65c0e787 and b410ad4619d296f9d37f0db3d0ff5b9066838b39)。要查看两个不同提交之间的差异,请使用git diff http://git-scm.com/docs/git-diff两次提交的修订说明符的前几个字符,如下所示:

# diff between commits 14b8... and b410...
git diff 14b8..b410
# only include diff of specified files
git diff 14b8..b410 path/to/file/a path/to/file/b

如果您想了解提交之间发生的所有差异的概述,请使用git log or git whatchanged http://git-scm.com/docs/git-whatchanged使用补丁选项:

# include patch displays in the commit history
git log -p
git whatchanged -p
# only get history of those commits that touch specified paths
git log path/a path/b
git whatchanged path/c path/d
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Git 中查看文件历史记录? 的相关文章

随机推荐