If you do not have local changes to the files that you want to save, the easiest way is to delete all the files, and then add the ones you want to save:
git rm -rf .
git checkout HEAD -- file1 file2
If you have local changes, first make or write them down.
source
share