How to revert uncommitted changes including files and folders?

前端 未结 14 1746
小鲜肉
小鲜肉 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:47

    git clean -fd
    

    didn't help, new files remained. What I did is totally deleting all the working tree and then

    git reset --hard
    

    See "How do I clear my local working directory in git?" for advice to add the -x option to clean:

    git clean -fdx
    

    Note -x flag will remove all files ignored by Git so be careful (see discussion in the answer I refer to).

提交回复
热议问题