问题描述
当我有.gitignore data / *
并运行 git clean -fd
时,数据文件夹及其所有内容文件被删除。
我想要的是删除一个git repo中的所有未经修改的文件,同时排除所有被忽略的文件(即不要删除gitignored文件)。我可以做什么?
除非您指定 -x
标志,但奇怪的是它会按照您的设置进行清理( folder / *
)。
@VonC评论说,你应该改变你的
.gitignore
忽略目录( data /
) ( data / *
)。 这是一个微妙的区别,但它对git很重要。
When I have .gitignore data/*
and run git clean -fd
, the data folder and all its content files are deleted.
What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete gitignored files). What could I do?
Git normally don't clean ignored files unless you specify the -x
flag, but strangely it cleans out when configured as you did (folder/*
).
As @VonC commented it out, you should change your .gitignore
to ignore the directory (data/
) rather than what's in it (data/*
).
It's a subtle difference, but it matters to git.
这篇关于如何在git clean -fd中保留所有被忽略的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!