git pull corresponds to the sequence of a git fetch and then git merge. So if you delete the files from your local repository, doing a git pull will not restore them.
In order to restore them you need to checkout that files from the remote repository using:
git checkout <branch name> -- <path/to/file>
<branch name> can be local or remote.
Example: Using remote repository
- Remote upstream name: origin
- Remote branch: feature/xpto
- Local branch: feature/xpto
- File missing on local branch: example.js
- Recover the file to the local branch from remote branch:
git checkout origin/feature/xpto -- example.js - Now you have
example.jsback on your local branch
Example 2: Rollback a commit
git log- Current commit hash
7bb2154cf23b68feb0a0bbbd95446f2cd8bf3a44 - Want to rollback to this commit hash
dbc04c23b2c6f2dd7bc9b5ef4aef22611a57c3adgit checkout dbc04c23b2c6f2dd7bc9b5ef4aef22611a57c3ad
- Only want to recover the file
example.jsfrom the above commit hashgit checkout dbc04c23b2c6f2dd7bc9b5ef4aef22611a57c3ad -- example.js