Restore a deleted Git commit

Sep 21, 2022 · 1 min read · Post a comment

As a part of Git restoring series, today we are going to look at how to restore a deleted Git commit. Without further ado follow the steps as described below.


  • Git


Step 1. List all commits:

git log

Once you find the commit SHA1 you have two options. Checkout or cherry-pick the commit. I would suggest the former one.

Step 2. Checkout the commit:

git checkout <commit-SHA1>

or, optionally cherry-pick it:

git cherry-pick <commit-SHA1>


List of related posts:

To find more neat Git commands and hacks, simply browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.