如何在Git中删除未跟踪的文件? [英] how to remove untracked files in Git?
问题描述
$ b
如果我想放弃最近在实验分支中添加的文件的所有更改,我该怎么办?未跟踪的文件如下所示:
$ git status
在分支上new_chick
未记录的文件:
(使用git add< file> ...来包含将要提交的内容)
.project
app / models / user.rb
db / migrate /
test / fixtures / users.yml
test / unit / user_test.rb
我试图运行git reset --hard,希望能够取消所有这些更改,但上面的所有文件仍然显示。
任何人都应该舍弃一些对我有用吗?
要删除未跟踪的文件/目录,请执行以下操作:
< pre $ git clean -fdx
-f - force
-d - 目录也是
-x - 也删除被忽略的文件(如果你不用,您想删除被忽略的文件)
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 index yet.
What do I have to do if I want to discard all the changes of the files recently added in my experimental branch? The untracked files are listed as below:
$ git status
On branch new_chick
Untracked files:
(use "git add <file>..." to include in what will be committed)
.project
app/models/user.rb
db/migrate/
test/fixtures/users.yml
test/unit/user_test.rb
I tried to run "git reset --hard" in hope to undo all those changes, but all the files above still show.
Anyone please shed some light on me?
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)
这篇关于如何在Git中删除未跟踪的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!