mercredi 3 juillet 2013

Restore Deleted Files using Git


Sometime you can delete a file  ,by accident, and then you commit your changes . after a while you recognize that you need this file So what you can do ??
what I have tried to resolve such problem (there are several ways) is  this few steps :
  1. List all files that have been deleted from my git repository :
    git log --diff-filter=D --summary
    
    
  2. Search the commit where you deleted your file
  3. undo your commit to the searched one BUT don't lose your modifications by taping this cmd :
    git reset --soft HEAD~n   
    

    n: is the number of undo commit steps

  4. if you type  git status  you will re-view your deleted file so to get the file back type this cmd :
    git checkout -- [file name]
    
Hope this could helps someone :D

Aucun commentaire:

Enregistrer un commentaire