Skip to main content
Relax constraints. File merely needs to exist in HEAD.
Source Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

If you deleted a file that was trackedexists in the previous commit, but didn't yetlatest HEAD commit the deletion, you can restore it using:

git checkout HEAD -- path/to/file.ext

If you deleted a file that was tracked in the previous commit, but didn't yet commit the deletion, you can restore it using:

git checkout HEAD -- path/to/file.ext

If you deleted a file that exists in the latest HEAD commit, you can restore it using:

git checkout HEAD -- path/to/file.ext
Reword. Format.
Source Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

I came to this question looking to restoreIf you deleted a file I just deletedthat was tracked in the previous commit, but I hadn'tdidn't yet committedcommit the change. Just in case you find yourself in this situationdeletion, all you need to do is the followingcan restore it using:

git checkout HEAD -- path/to/file.ext

git checkout HEAD -- path/to/file.ext

I came to this question looking to restore a file I just deleted but I hadn't yet committed the change. Just in case you find yourself in this situation, all you need to do is the following:

git checkout HEAD -- path/to/file.ext

If you deleted a file that was tracked in the previous commit, but didn't yet commit the deletion, you can restore it using:

git checkout HEAD -- path/to/file.ext
Source Link
Brett
  • 4.2k
  • 9
  • 39
  • 50

I came to this question looking to restore a file I just deleted but I hadn't yet committed the change. Just in case you find yourself in this situation, all you need to do is the following:

git checkout HEAD -- path/to/file.ext