I recently cloned a repository on my local machine and then did a git remove on one of the files and pushed those changes back to the github repository. My question is how do I restore that file back on the original github repository?
To recover deleted files you will be provided with a single file recovery option and all files recovery option. If you want to recover a single file, you can go with “-restore-file”. On the other hand, if you want to restore all deleted files, you can go with “-restore-all”.
You can delete an individual file or an entire directory in your repository on GitHub. People with write permissions can delete files or directories in a repository.
The process for recovering a deleted commit is quite simple. All that is necessary is to use `git reflog` to find the SHA value of the commit that you want to go to, and then execute the `git reset --hard <sha value>` command.
If you can find a previous commit abcd
that has the deleted file, then you can use
git checkout abcd file-to-restore
to restore it. You'll need to commit the file again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With