How to bring back removed file
In GIT working repo i removed couple of files with command rm -rf not git rm, When i try to pull/fetch from the server(bare 开发者_Go百科repo) files are not visible. How do i bring those file back ?
Revert to a previous commit. This will reset to last committed state:
git reset --hard HEAD
Note...if you have other changes...be SURE you stash them first!
git stash
Here is an option taken from another post that might help you as well:
git checkout abcde file/to/restore
Where abcde is the commit #. You can use:
git log
To get commit log.
Reset or revert a specific file to a specific revision using Git?
I'd recommend git checkout path/to/file.ext
if you only want to restore a single file (or do it a couple of times for a couple of files). Using git reset --hard HEAD
will get all of your files back, but it will also wipe out any other changes you've made since your last commit that you might want to keep.
Always inspect the output of
git status
when in doubt. The output would have showed you how to get said filles back.
This would include instructions for deleted files and files/changes that got added to the index.
精彩评论