how to remove untracked files in Git?

后端 未结 8 959
鱼传尺愫
鱼传尺愫 2020-12-22 15:22

I\'m working on a branch, say \"experimental\" branch which I branch out from my master branch.Then, I generate a user model in experimental branch, but does not add them to

相关标签:
8条回答
  • 2020-12-22 16:06

    To remove untracked files / directories do:

    git clean -fdx
    

    -f - force

    -d - directories too

    -x - remove ignored files too ( don't use this if you don't want to remove ignored files)


    Use with Caution!
    These commands can permanently delete arbitrary files, that you havn't thought of at first. Please double check and read all the comments below this answer and the --help section, etc., so to know all details to fine-tune your commands and surely get the expected result.

    0 讨论(0)
  • You may also return to the previous state of the local repo in another way:

    1. Add the untracked files to the staging area with git add.
    2. return to the previous state of the local repo with git reset --hard.
    0 讨论(0)
提交回复
热议问题