Chr*_*ken 84
.git文件夹仅存储在repo的根目录中,而不是所有子目录(如subversion).您应该能够删除那个文件夹,除非您使用子模块...然后他们也会有一个.
Eri*_*ski 48
如何删除.gitLinux中文件夹下的所有目录.
运行此find命令,它将列出.git当前文件夹下的所有目录:
find . -type d -name ".git" \
&& find . -name ".gitignore" \
&& find . -name ".gitmodules"
Run Code Online (Sandbox Code Playgroud)
打印:
./.git
./.gitmodules
./foobar/.git
./footbar2/.git
./footbar2/.gitignore
Run Code Online (Sandbox Code Playgroud)
应该只有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.
Run Code Online (Sandbox Code Playgroud)
jwe*_*ich 15
您可以使用git-archive,例如:
git archive master | bzip2 > project.tar.bz2
Run Code Online (Sandbox Code Playgroud)
master所需的分支在哪里.
小智 8
cd 然后到存储库
find . -name ".git*" -exec rm -R {} \;
Run Code Online (Sandbox Code Playgroud)
确保不要意外地将单个点,斜杠,星号或其他正则表达式通配符传输到find中,否则rm将很乐意将其删除.
万一其他人偶然发现了这个话题 - 这里有一个"一刀切"的解决方案.
如果您正在使用.git或.svn,则可以使用--exclude-vcstar选项.这将忽略不同版本控制系统所需的许多不同文件/文件夹.
如果您想了解更多信息,请查看:http: //www.gnu.org/software/tar/manual/html_section/exclude.html