LoginSignup
0
0

More than 3 years have passed since last update.

【Git】過去の状態に戻すときのコマンド

Last updated at Posted at 2020-07-20

概要

最近Gitの勉強をしています.過去のコミットした状態に戻したいときの選択肢として,git reset --hard <commit_id>git checkout <commit_id>があります.これらの違いがいまいちよく分からなかったので調査中です.

git reset --hard <commit_id>

これは基本通りの型です.

git checkout <commit_id>

これは少し特殊な方法だと思います.そもそもcheckoutというのはブランチを切り替えるためのコマンドです.参考(1)でもcheckoutの応用編としてこちらの使い方を紹介しています.

参考

(1) 【 git checkout 】コマンド(応用編)――ワークツリーを特定のブランチやコミットに切り替える
この記事自体は無料会員にならないとみれないかもです.
(2)Git の 'detached HEAD' 状態とその注意点
(3)git reset & git checkout 使い分けまとめ
(4)「git checkout 」はブランチを「ブランチなし」に変更しています
(5)7.7 Git のさまざまなツール - リセットコマンド詳説
(6)[git] 戻したい時よく使っているコマンドまとめ

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