I had up to date repository. Then I had deleted several files and this was mistake. I would like to get fresh repository back. I do
$ git pull origin master
And expect to get everything from server, but getting message that everything is up to date.
How to get my sources from server using git pull
then?
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.
In the top right corner of GitHub.com, click your profile photo, then click Your organizations. Next to the organization, click Settings. In the left sidebar, click Deleted repositories. Next to the repository you want to restore, click Restore.
You can reset local branch to what's at remote
git reset --hard origin/main
The files are in your local git history so you won't need to pull code to get them back. Run
git checkout <file>
on the missing files. If you don't have any uncommited changes then
git checkout .
in the git root directory will work as well.
This shows all the deleted files.
git ls-files --deleted
This will restore the deleted file.
git checkout <deleted file name with complete path>
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