How to revert uncommitted changes including files and folders?

前端 未结 14 1811
小鲜肉
小鲜肉 2020-11-28 17:07

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?

14条回答
  •  鱼传尺愫
    2020-11-28 17:23

    You can just use following git command which can revert back all the uncommitted changes made in your repository:

    git checkout .
    

    Example:

    ABC@ABC-PC MINGW64 /c/xampp/htdocs/pod_admin (master)
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add ..." to update what will be committed)
      (use "git checkout -- ..." to discard changes in working directory)
    
            modified:   application/controllers/Drivers.php
            modified:   application/views/drivers/add.php
            modified:   application/views/drivers/load_driver_info.php
            modified:   uploads/drivers/drivers.xlsx
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
    ABC@ABC-PC MINGW64 /c/xampp/htdocs/pod_admin (master)
    $ git checkout .
    
    ABC@ABC-PC MINGW64 /c/xampp/htdocs/pod_admin (master)
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    nothing to commit, working tree clean
    

提交回复
热议问题