在颠覆下,我可以使用TortoisesVN查看文件的历史记录/日志。

我该如何用git做到这一点?

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

有帮助吗?

解决方案

利用 git log 查看提交历史。每个提交都有一个关联的修订说明符,这是哈希密钥(例如 14b8d0982044b0c49f7a855e396206ee65c0e787b410ad4619d296f9d37f0db3d0ff5b9066838b39)。要查看两个不同的提交之间的区别,请使用 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 或者 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

其他提示

看起来你想要 git差异 和/或 git日志. 。也要结帐 gitk

gitk path/to/file
git diff path/to/file
git log path/to/file

我喜欢使用 gitk name_of_file

这显示了每个提交文件中文件发生的更改的不错列表,而不是显示所有文件的更改。使追踪发生的事情变得更容易。

你也可以使用 提格 对于基于NCURSES的良好git存储库浏览器。查看文件的历史记录:

tig path/to/file

我最喜欢的是 git log -p <filename>, ,这将为您提供给定文件的所有提交以及每个提交的差异的历史记录。

许多GIT历史记录浏览器,包括 git log (和'git log -graph'),gitk(在tcl/tk中,git的一部分),qgit(in qt),tig(tig(使用ncurses的文本模式接口,使用ncurses),giggle(gtk+),tortoisegit和git git -Cheetah支持路径限制(例如 gitk path/to/file).

当然,如果您想要尽可能接近乌龟的东西,您可以只使用 .

git-diff 或者 git-log ?

Tortoisegit也提供了 命令行工具 要查看文件的历史记录。使用PowerShell:

C:\Program` Files\TortoiseGit\bin\TortoiseGitProc.exe /command:log /path:"c:\path\to\your\file.txt"

git log --all -- path/to/file 应该管用

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top