Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

How to preserve all ignored files in git clean -fd?

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?

question from:https://stackoverflow.com/questions/19442616/how-to-preserve-all-ignored-files-in-git-clean-fd

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Git normally doesn't clean ignored files unless the -x flag is specified, but strangely it cleans out when configured as you did (folder/*).

As @VonC pointed out, you should change your .gitignore-file to ignore the directory (data/) rather than its contents (data/*).

It's a subtle difference, but it matters to git.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...