Undoing changes

You are in the right place if you have nuked the repo and now in search to reset the changes ...

me after committing crashed code

Case -1 : Code is still in the staged format

git reset <filename>
git reset ## This will reset all staged changes (all files)

Case -2 : Code is commited but not yed pushed into main

git reset HEAD~1

Here the HEAD is the current stage of the repo and we are rolling it back by "1" point

Case -3 : Code is commited more than once and later you know it was nuked

Here we are meant to roll back to the safest commit we have done before (EX : 2 to x commits back)

git reset <commit hash>

Case -4 : We are looking to get our code back to normal

git reset --hard <commit hash>

Last updated