How to remove local (untracked) files from the current Git working tree

前端 未结 30 2560
死守一世寂寞
死守一世寂寞 2020-11-22 00:07

How do you delete untracked local files from your current working tree?

30条回答
  •  耶瑟儿~
    2020-11-22 00:43

    Remove all extra folders and files in this repo + submodules

    This gets you in same state as fresh clone.

    git clean -ffdx
    

    Remove all extra folders and files in this repo but not its submodules

    git clean -fdx
    

    Remove extra folders but not files (ex. build or logs folder)

    git clean -fd
    

    Remove extra folders + ignored files (but not newly added files)

    If file wasn't ignored and not yet checked-in then it stays. Note the capital X.

    git clean -fdX
    

    New interactive mode

    git clean
    

提交回复
热议问题