gitgit-commitgit-resetgit-revertgit-clean

How can I revert uncommitted changes including files and folders?


Is there a Git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?


Solution

  • You can run these two commands:

    # Revert changes to modified files.
    git reset --hard
    
    # Remove all untracked files and directories.
    # '-f' is force, '-d' is remove directories.
    git clean -fd