Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Git Tutorial 33 – How To Restore Deleted And Committed But Not Pushed File By GIT Reset?

Posted on 04/23/2025 By admin

As a part of GIT Tutorials End To End, we will learn about retrieving a deleted and committed file in Git by using GIT reset command.

I will expect that you are aware of the basic concepts and commands of GIT. But if you are a beginner in GIT then I strongly recommend you to refer GIT Basic Commands and Concepts section on my blog first.

You must go through the below posts to understand the flow –

How To Retrieve Deleted But Not Committed File In Git

How To Restore Deleted And Committed But Not Pushed File Without GIT Reset

In the previous post, we deleted the file but did not commit it. In this post, the scenario will be a little different. I will delete the file and will commit it as well. Please note that the commit will be local and will not be pushed to the remote repo.

Let’s create a GIT repository and some files with contents.

Add and commit.

Now let’s delete a file and commit the change i.e. deletion.

In the previous post, we recovered the deleted file using the checkout command because the deleted file was not committed. Let’s run the same command again in this scenario.

We will see an error as above. As I have explained in my previous post that deleted file is recovered from the last commit i.e. HEAD. We have deleted the file but the deletion was not committed. So HEAD was still pointing to the commit in which deleted file was present. In this post, we have deleted the file and also committed the changes. Committing the changes will create a new commit id and HEAD will point to that. So when we used the checkout command in this condition, GIT tries to recover the file from the latest commit i.e. HEAD but the latest commit does not have that file because the latest commit actually has changes to delete the file.

In the last post, we already learned to retrieve a deleted file from a previous commit. In this post, we will use the git reset command to retrieve the deleted file.

I have already explained the Git reset command with soft, mixed and hard options. I will just undo the last commit with a mixed option.

We are at the stage when we actually deleted the file and now we have a chance to restore it.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe to my YouTube channel.
#ThanksForReading
#HappyLearning

Uncategorized

Post navigation

Previous Post: Missing Firebug? ‘Rūto’ is On The Way ==>
Next Post: How To Remove Duplicate Values From List Using Java Stream API?

Related Posts

July 2018 – Make Selenium Easy Uncategorized
Arguments – Make Selenium Easy Uncategorized
Make Selenium Easy – Page 17 Uncategorized
May 1, 2018 – Make Selenium Easy Uncategorized
Java Interview Question – Explain public static void main(String[] args) Uncategorized
allPkgFromMain – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark