I deleted a file on my desktop by mistake, how can I get it from the remote master?
You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.
A deleted Git branch can be restored at any time, regardless of when it was deleted. Open your repo on the web and select the Branches view. Search for the exact branch name using the Search all branches box in the upper right. Click the link to Search for exact match in deleted branches.
git checkout -- /path/to/file
should be enough to restore it, since you have a local repo with that file in it.
That would restore your file at the version of the file present in the index.
(i.e. the last version you ran git add
on it).
To restore it at the latest commit of your current branch:
git checkout HEAD -- /path/to/file
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