LoginSignup
1
0

More than 3 years have passed since last update.

【Git】HEADとは何か

Posted at

プログラミング勉強日記

2021年3月22日

HEADとは

 現在のブランチの最後のコミットの代名詞のこと。現在使用しているブランチの先頭を表す。デフォルトではmasterの先頭を表していて、HEADが移動することで使用するブランチが変更される。

HEADの使い方

 コミットを指定するときに~(チルダ)と^(キャレット)を使って、あるコミットからの相対位置で指定することもできる。~を後ろに書くと行くつ前の親かを指定することができ、^はブランチのマージがオヤッが複数ある場合に何番目の親化を指定できる。

最後にコミットした内容を見る方法
$ git show HEAD
最後の1つ前のコミットを見る方法
$ git show HEAD^
最後の2つ前のコミットを見る方法
$ git show HEAD^^
$ git show HEAD~2

参考文献

Git初心者に捧ぐ!Gitの「これなんで?」を解説します。
ブランチの切り替え

1
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
1
0