0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

過去の特定の時点にレポジトリを戻したい

Posted at

過去の特定の時点にレポジトリを戻す方法

過去の特定の時点にレポジトリを戻したい場合は、git checkoutコマンドを使用します。

例: コミットIDが0edb1a0の時点にレポジトリを戻したい場合

git checkout 0edb1a0

git checkoutは通常、ブランチ間の移動に使用されるコマンドとして知られていますが、このように特定のコミットに移動する機能も備えています。

ただし、この操作を実行すると、リポジトリはdetached HEADという状態になります。これは、どのブランチにも所属していない状態を意味します。この状態で新たにコミットを作成し、その後別のブランチに切り替えたりすると、作成したコミットが失われる可能性があるため注意が必要です。

環境

  • git version 2.43.0.windows.1
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?