Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve missing files from remote repo?

I accidentally deleted a few files from my local git repo.

I have not pushed this change to the remote.

Is there a easy way to get these files back from the remote?

Normally I would just do a git clone but it seems there should be a better way.

like image 801
Zombo Avatar asked Apr 01 '26 05:04

Zombo


2 Answers

git checkout .

How do I discard unstaged changes in Git?

like image 158
Zombo Avatar answered Apr 04 '26 07:04

Zombo


You should just be able to either revert the commit with the deletions, or reset HEAD to the commit before you did the deletes, depending on whether you want to keep the deletions in the history or not.

Alternatively, if you haven't committed the deletes yet, you can just checkout the deleted files to restore them from your local repo.

like image 25
dunedain289 Avatar answered Apr 04 '26 06:04

dunedain289



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!