Reputation: 761
I have local project for which i created remote github repo. I didn't often push my local changes to remote repo but sometimes doing it. Recently while i was working on local project i have deleted some files using
rm fileName
After deleting i want to restore them and easiest way i think about was retrieving deleted files from github repo I have only one master branch in my repo and i tried
git fetch
And console prompt me that all files up to date after checking files which i need i didnt find them. After it i tried
git pull
and also i got notification that all files up to date and files which i need didnt uploaded to my local repo. I thought that maybe those files which i need haven't in remote repo but after checking i found them there. What i am doing wrong ?? How i should retrieve nedeed files ??
Upvotes: 1
Views: 454
Reputation: 1329492
Instead of playing with git checkout
(too confusing) or git reset
, the proper command (with a recent Git version 2.23+) would be to use git restore
.
git restore
... restore files.
In your case, you want the version which was in the index restored to your working tree (assuming your file was already tracked):
git restore -s@ -SW -- yourFile
It will restore the file from the last commit, and update both working tree and index, completely restoring the file.
Upvotes: 1