LoginSignup
0
0

More than 1 year has passed since last update.

[Git] 動作を試す 実行例8:showで過去のファイル内容を表示する

Last updated at Posted at 2023-04-29

Gitの動作を理解するために、Gitのコマンドを実際に試して、結果を見てみました。

1つの記事内で一連のGitコマンドが完結しているので、これら一連のコマンドを順に実行させて結果を見ることで、一連のGitの動作を実際に体感でき、一通り独習することが可能です。

※前回記事のリポジトリ状態からの続きになっています。

前回記事へ 目次へ:Git関連記事のまとめページ 次回記事へ

実行例

※1つ前のtest1.txtファイル内容を表示する
git show "HEAD^":test1.txt
↓
結果: 
Sample-Added-11
Sample-Added-12
Sample-Added-13

(※現在のファイル内容と比較すると)
type test1.txt
↓
結果: 
Sample-Added-11
Sample-Added-12
Sample-Added-13
Sample-Added-14

※コミットSHA値で指定してファイル内容を表示する
git show 20bbab7:test1.txt
↓
結果: 
Sample-Added-11
Sample-Added-12
Sample-Added-13

git show 20bbab7:test2.txt
↓
結果: 
Sample-Added-**21

※2つ指定すると、続けてファイル内容が表示される
git show 20bbab7:test1.txt 20bbab7:test2.txt
↓
結果: 
Sample-Added-11
Sample-Added-12
Sample-Added-13
Sample-Added-**21

git show 00cad71:test1.txt
↓
結果: 
Sample-Added-11
Sample-Added-12

git show master:test1.txt
↓
結果: 
Sample-Added-11
Sample-Added-12
Sample-Added-13
Sample-Added-14

環境

Windows 10、PortableGit-2.40.0-64-bitを使用、全てローカルPC上で実施、GitHub等は不使用。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0