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