Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I undelete a file after git rm and pushing to github?

Tags:

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?

like image 478
Alex Chao Avatar asked Oct 07 '13 00:10

Alex Chao


People also ask

Can you get a file back after rm?

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”.

Can I delete local files after pushing to GitHub?

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.

Can I get back deleted commit git?

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.


1 Answers

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.

like image 94
acj Avatar answered Oct 01 '22 06:10

acj