How to revert uncommitted changes including files and folders?

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

    A safe and long way:

    1. git branch todelete
    2. git checkout todelete
    3. git add .
    4. git commit -m "I did a bad thing, sorry"
    5. git checkout develop
    6. git branch -D todelete
    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题