-2

I have folder with migrations. I accidentally deleted most of the migrations, only few left. How to restore only delete migrations from the last commit without overwriting current files ? Or just restore migration folder? I the could edit them once more. Folder is app/models.

user1692333
  • 2,461
  • 5
  • 32
  • 64
  • possible duplicate of [Restore a deleted file in a Git repo](http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo) – Joe Apr 19 '15 at 12:31

2 Answers2

1

git checkout -- app/models will revert any changes made to app/models since the last commit, including restoring the files you deleted.

Dogbert
  • 212,659
  • 41
  • 396
  • 397
0

you have several options:

  • git log --diff-filter=D --summary

  • checkout new branch and 'revert' the wrong commit. it will "return" all the deleted files

  • use git reflog to return tot the desired point in time and create branch from this point
  • use git cat-file to view the content of the commit and extract the date form the commit

to restore the deleted files: git ls-files -d | xargs git checkout --

CodeWizard
  • 128,036
  • 21
  • 144
  • 167