git show
git
用法
git show [<object>|<commit>:<path>]把一个提交的说明和改动一起打印出来;写成 <commit>:<path> 就能取出文件的旧内容而不动你的工作副本。
常用选项
| 选项 | 含义 |
|---|---|
| --stat | file summary instead of the full patch |
| --name-only | list the paths the commit touched |
| -s | message only, no diff |
| <commit>:<path> | print the file as it was in that commit |
| --pretty=fuller | show author and committer dates separately |
示例
git show HEADthe message and diff of the last commit
git show HEAD~2:src/app.tsprints an old version of a file without touching your copy
git show --stat v1.2.0what the tagged commit changed, file by file
难的地方在于撤销有好几种:把分支的指向挪走,和补一个反向提交,不是一回事。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. git show 是做什么的?
把一个提交的说明和改动一起打印出来;写成 <commit>:<path> 就能取出文件的旧内容而不动你的工作副本。
Q. 怎么写?
git show [<object>|<commit>:<path>] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 5 个,完整列表在 man git。这条命令属于git。
相关命令
man 手册: man git-show