【发布时间】:2010-12-19 15:39:06
【问题描述】:
【问题讨论】:
标签: git timeline git-diff git-log revision-history
【问题讨论】:
标签: git timeline git-diff git-log revision-history
【讨论】:
使用git log 查看提交历史。每个提交都有一个关联的修订说明符,它是一个哈希键(例如 14b8d0982044b0c49f7a855e396206ee65c0e787 和 b410ad4619d296f9d37f0db3d0ff5b9066838b39)。要查看两个不同提交之间的差异,请将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 log(和 'git log --graph')、gitk(在 Tcl/Tk 中,Git 的一部分)、QGit(在 Qt 中)、tig(到 Git 的文本模式接口, using ncurses), Giggle (in GTK+), TortoiseGit 和 git-cheetah 支持路径限制(例如,gitk path/to/file)。
【讨论】:
当然,如果你想要尽可能接近 TortoiseSVN 的东西,你可以使用TortoiseGit。
【讨论】:
我喜欢使用 gitk name_of_file
这显示了每次提交时文件发生的更改的漂亮列表,而不是显示所有文件的更改。更容易追踪发生的事情。
【讨论】:
TortoiseGit 还提供了command line tool 来查看文件的历史记录。使用PowerShell:
C:\Program` Files\TortoiseGit\bin\TortoiseGitProc.exe /command:log /path:"c:\path\to\your\file.txt"
【讨论】:
我最喜欢的是git log -p <filename>,它会为您提供给定文件的所有提交的历史记录以及每次提交的差异。
【讨论】:
git log --all -- path/to/file 应该可以工作
【讨论】:
--all?它应该做什么? (但没有“编辑:”、“更新:”或类似的 - 答案应该看起来好像是今天写的。)