Last active
October 31, 2025 07:56
-
-
Save naokazuterada/9e45a937f7574ebf91a7 to your computer and use it in GitHub Desktop.
git rebaseを間違えた時に元に戻す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git reflog | |
| # これで、以下の様なのが参照できる | |
| 2be6f11 HEAD@{0}: xxxxxxxxxxxx | |
| 18389ad HEAD@{1}: xxxxxxxxxxxxx | |
| 0c485c8 HEAD@{2}: xxxxxxxxxxxxxx | |
| b751438 HEAD@{3}: xxxxxxxxxxxxxxx # ここに戻したいので一つ前の数字を指定↓ | |
| hc8a0s8 HEAD@{4}: xxxxxx | |
| # 備考 | |
| # 下記のようにすると、日付で確認できるので便利 | |
| git reflog --date=local # ローカルタイムで表示 | |
| # その他 | |
| git reflog --date=short # YYYY-MM-DD | |
| git reflog --date=relative # "2 hours ago" のように相対表示 | |
| git reflog --date=iso # ISO 形式の日付 | |
| # 「q」で戻って・・・ | |
| git reset --hard 'HEAD@{4}' | |
| # のように数字を指定すると元に戻る! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment