Restore deleted files in GitHub WebSite
As a short answer, you can't restore deleted files and revert changes in the commits at the GitHub website, instead, you should use the GitHub desktop.
Where can I find the files that I have deleted on the GitHub website?
There is no such Recycle bin or Trash for the deleted files, instead, you should check the Commits to track the history of your updates in the tp of your GitHub repository as shown below.
After clicking on Commits, you can find all changes that you have done like adding a new file, update a file, delete a file ...etc, and the GitHub commits are categorized by Date and order by newer to older as you can see.
Note: On the GitHub website, you can easily Revert a Pull Request. however, you can't perform "Revert changes in commits", and you should use the GitHub desktop as I have earlier mentioned.
How to revert commits in GitHub Desktop?
- Download and install the GitHub desktop from https://desktop.github.com/.
- Connect to your GitHub account.
- From the "File" menu, click on "Clone Repository ".
- Select the Repository that you would like to clone from github.com and specify where you need to save it locally.
- Now, click on "Fetch Origin" to get all files and commits for this Repository.
- Click on the "History" tab to check all commits in GitHub Desktop.
- Right-click on the commit that you would like to revert > Select "Revert Changes in Commit".
- Now, click on "Push Origin" to apply the revert action.
- Go back to check the deleted file on the GitHub website, you will note that the deleted file has been recovered successfully as shown below:
Note: To revert multiple commits, it's strongly recommended to revert changes in order from newest to oldest to avoid merge conflicts.
See Also