How to revert a “git rm -r .” ?

How to revert a “git rm -r .” ?

Asked on January 8, 2019 in Git.
Add Comment


  • 3 Answer(s)

    Here the following below code:

    git reset HEAD
    

    Don’t have any uncommitted changes.

    git reset --hard HEAD
    

    The first required does not work, then save your uncommitted changes with git stash:

    git stash
    git reset --hard HEAD
    git stash pop
    
    Answered on January 8, 2019.
    Add Comment

    You can easily checkout the individual files you missed/removed :

    git checkout HEAD path/to/file path/to/another_file
    
    

    Single changes intact with no computing.

    Answered on January 8, 2019.
    Add Comment

    Single file and folder for revert a “git rm -r :

    git reset -- path/to/file
    git checkout -- path/to/file
    

    First create agian the entries index  from path/to/file and then  recreate the HEAD file.

    To create again the files from an older commit from git reset –help and git checkout –help.

    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.