Linux命令删除.git文件夹以外的所有文件? [英] Linux command to delete all files except .git folder?

查看:421
本文介绍了Linux命令删除.git文件夹以外的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我复制之前,我想 >删除 .git / 文件夹以外的所有当前目录内容新的文件进入分支。

I want to delete all of the current directory's content except for the .git/ folder before I copy the new files into the branch.

什么是linux命令?

What's the linux command for that?

推荐答案

prune选项。

With find and prune option.

find . -path ./.git -prune -o -exec rm -rf {} \; 2> /dev/null


编辑:两个目录 .git dist

find . -path ./.git -prune -o \( \! -path ./dist \) -exec rm -rf {} \; 2> /dev/null

这篇关于Linux命令删除.git文件夹以外的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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