10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[GitHub Desktop] 過去の履歴に戻す方法 (スクショ付)

Last updated at Posted at 2021-01-06

今回laravelでmodelやマイグレーションをした際にとんでもないミスをしたのでGitHub Desktop を使って過去の履歴に戻す方法を備忘録として投稿します。

###はじめに
全てPushした状態にした状態で始めて下さい

###投稿者の環境

  1. MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)
  2. macOS Big Sur バージョン11.0.1

ステップ 1

  1. 戻したいコミットにカーソルを合わせて右クリックする
  2. Copy SHAをクリックするとコミット履歴番号を取得できます
    “スクリーンショット” 2021-01-05 20.39.11.jpg

ステップ 2

Repository⇨Open in Terminalでターミナルを開く
“スクリーンショット” 2021-01-05 20.43.08.jpg

ステップ 3

するとターミナルが開くので、そこに下記のコマンドを入力します。
xxxxxの部分は先ほどコピーしたSHAをペーストしてください。
実行をするとそのコミットに戻ることができます

ターミナルにて
git reset --hard xxxxx(xxxxxにSHAをコピペ)

“スクリーンショット” 2021-01-05 20.44.42.jpg

改めてGitHub Desktopの便利さに気づきました。また、ブランチでちゃんと分けてなおかつ細かくPushしたので助かりました💦

10
8
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
10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?