I was working on my Spring Boot app when I accidentally moved the folder that contained the Git repository into another directory. When I tried to load it in Spring Tools Suite (STS), the IDE — due to its workspace cache — treated it as a new project. Not realizing this, I deleted the “new” project from the workspace, and all the changes I had made were gone.

I tried pulling it from the remote repository, but the local folder was missing.

So, I decided to restore the files from an earlier commit in my GitHub repository — before I made the mistake.

This is how I did it!

Step 1: Make sure you’re on the main branch

git checkout master
(or git checkout main depending on your branch name)

Step 2: Create a new branch to restore from old commit

This protects your cu…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help