我有一个受版本控制的文件夹。我想复制它以发送,但不想包含所有 .git 目录及其下面的文件。
有没有办法删除所有 git 文件,而不是手动删除所有文件?
如何全部删除.git
Linux 中文件夹下的目录。
运行这个 find 命令,它将列出所有.git
当前文件夹下的目录:
find . -type d -name ".git" \
&& find . -name ".gitignore" \
&& find . -name ".gitmodules"
Prints:
./.git
./.gitmodules
./foobar/.git
./footbar2/.git
./footbar2/.gitignore
应该只有3或4个左右.git
目录,因为 git 每个项目只有一个 .git 文件夹。你可以rm -rf yourpath
以上每一项都是手工完成的。
如果您想通过一个命令将它们全部删除并生活在危险之中:
//Retrieve all the files named ".git" and pump them into 'rm -rf'
//WARNING if you don't understand why/how this command works, DO NOT run it!
( find . -type d -name ".git" \
&& find . -name ".gitignore" \
&& find . -name ".gitmodules" ) | xargs rm -rf
//WARNING, if you accidentally pipe a `.` or `/` or other wildcard
//into xargs rm -rf, then the next question you will have is: "why is
//the bash ls command not found? Requiring an OS reinstall.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)