Reputation: 15594
I deleted several folders and files from the local repository I have just selected them and deleted them. (including the folders like 'images' , 'config' ..etc and some files which have modifications done by me and not needed anymore)
I tried git pull upstream master
and git fetch upstream master
to get those files and folders back to my local repository.
What I did is basically like,
*I have used SVN and there I can delete any file from the repo and when I get an update the file will be back. But I don't know how to do that with GIT.*
So is there any way I can get those deleted files back safely and have those fresh copies.?
Note : I did not commit the deletions
Upvotes: 0
Views: 76
Reputation: 17240
Frist use git status
to look what files you have deleted and then use git checkout filename_or_dir_name
to resume them.
e.g.:
# atupal at atupal in /tmp/tmp [18:15:39]
$ git status .
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: a
no changes added to commit (use "git add" and/or "git commit -a")
# atupal at atupal in /tmp/tmp [18:15:41]
$ ls
# atupal at atupal in /tmp/tmp [18:15:47]
$ git checkout .
# atupal at atupal in /tmp/tmp [18:15:51]
$ ls
a
# atupal at atupal in /tmp/tmp [18:15:55]
$
If you have staged modified files by using git add file_name
, then after git-checkout
the resumed file is "fresh", other not.
Upvotes: 1