Say I\'m in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I find I need to restore that file.
I know
You could always git revert
your commit which deleted the file. (This assumes that the deletion was the only change in the commit.)
> git log
commit 2994bda49cd97ce49099953fc3f76f7d3c35d1d3
Author: Dave
Date: Thu May 9 11:11:06 2019 -0700
deleted readme.md
And if you've continued work, and realized later that you didn't want to commit that deletion commit, you could revert it using:
> git revert 2994bd
Now git log
shows:
> git log
Author: Dave
Date: Thu May 9 11:17:41 2019 -0700
Revert "deleted readme"
This reverts commit 2994bda49cd97ce49099953fc3f76f7d3c35d1d3.
And readme.md
has been restored into the repository.