如何在git clean -fd中保留所有被忽略的文件? [英] How to preserve all ignored files in git clean -fd?

查看:210
本文介绍了如何在git clean -fd中保留所有被忽略的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有.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中保留所有被忽略的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆