Is there a quick git command to see an old version of a file?
在git中是否有命令可以查看(转储到标准输出或$PAGER
或$EDITOR
)特定版本的特定文件?
You can use git show
:
$ git show REVISION:path/to/file
For example, to view the version of file src/main.c
from 4 commits ago, use:
$ git show HEAD~4:src/main.c
Note that the path is from the root of the repository unless it starts with ./ or ../ to indicate a relative path. For more information, check out the man page for git-show
.
Doing this by date looks like this:
git show HEAD@{2013-02-25}:./fileInCurrentDirectory.txt
Note that HEAD@{2013-02-25}
means "where HEAD was on 2013-02-25" in this repository (using the reflog), not "the last commit before 2013-02-25 in this branch in history".
If you like GUIs, you can use gitk:
start gitk with:
gitk /path/to/file
Choose the revision in the top part of the screen, eg by description or date. By default, the lower part of the screen shows the diff for that revision, (corresponding to the "patch" radio button).
To see the file for the selected revision:
上一篇: Git提交消息:50/72格式