Skip to content

Instantly share code, notes, and snippets.

@naokazuterada
Last active May 15, 2024 05:40
Show Gist options
  • Save naokazuterada/9e45a937f7574ebf91a7 to your computer and use it in GitHub Desktop.
Save naokazuterada/9e45a937f7574ebf91a7 to your computer and use it in GitHub Desktop.
git rebaseを間違えた時に元に戻す
git reflog
# これで、以下の様なのが参照できる
2be6f11 HEAD@{0}: xxxxxxxxxxxx
18389ad HEAD@{1}: xxxxxxxxxxxxx
0c485c8 HEAD@{2}: xxxxxxxxxxxxxx
b751438 HEAD@{3}: xxxxxxxxxxxxxxx # ここに戻したいので一つ前の数字を指定↓
hc8a0s8 HEAD@{4}: xxxxxx
# 「q」で戻って・・・
git reset --hard 'HEAD@{4}'
# のように数字を指定すると元に戻る!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment