Git: How to remove ignored files from your repository's directory

本文介绍如何使用git clean命令配合-x选项来移除被.gitignore忽略的文件。这有助于整理工作目录,使其更整洁。

转自:  https://makandracards.com/makandra/17529-git-how-to-remove-ignored-files-from-your-repository-s-directory


When you have files in your .gitignore they won't be considered for changes, but still you might want to get rid of them, e.g. because they clutter your file system.

While a regular git clean will ignore them as well, passing the -x switch changes that:

COPY
git clean -x

If you want to see what would happen first, make sure to pass the -n switch for a dry run:

COPY
git clean -xn

Clean even harder by passing the -f (force cleaning under certain circumstances; I think this is also required by default) or -d (removes directories) switches:

COPY
git clean -xdf

Careful: You may be ignoring local config files like database.yml which would also be removed. Use at your own risk.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值