How to get the deleted files back when...
- Files are
rm? - Files are
git rm? - Files are
git rmandgit commit?
How to get the deleted files back when...
rm ?git rm ?git rm and git commit ?rmIf you know which files are removed:
git check -- filename
or
git checkout-index filename
If you don't know which files are removed or there are too many removed files:
git ls-files -d | xargs git checkout --
git rmUse reset to roll back the index first
git reset HEAD
And use the commands listed above
git ls-files -d | xargs git checkout-index
git rm and git commitIf you know which commit(ex: 2ae853) you remove the files, you can checkout files from the previous commit(2ae853^) of that commit:
git checkout 2ae853^ -- filename
If you forget which commit you removed the files, use rev-list to find the commit first:
git rev-list -n 1 HEAD -- filename
And use the previous command to get the files back.