github/gitignore · Global/Linux.gitignore
Linux .gitignore 模板详解
说明 Linux.gitignore 忽略编辑器备份(*~)、FUSE 与 NFS 临时文件、KDE .directory、废纸篓目录和 nohup.out 的原因。
Linux.gitignore 是只有 6 行的简短模板,只处理 Linux 桌面和文件系统生成的副产物。它同样适合放在个人全局 gitignore 中。
每条规则都针对只在特定情况下生成的文件。例如 .nfs* 只出现在 NFS 挂载中,.fuse_hidden* 只出现在 FUSE 文件系统中。
逐条规则详解
| 模式 | 忽略什么,为什么忽略 |
|---|---|
*~ | 编辑器备份Emacs、gedit、nano 等保存时留下的 文件名~ 备份。忽略所有名称以波浪号结尾的文件。 |
.fuse_hidden*.nfs* | FUSE 与 NFS 临时文件删除已打开的文件时,文件系统为推迟实际删除而改名保留的文件。进程关闭文件后就会消失。 |
.directory | KDE 文件夹设置KDE Dolphin 文件管理器保存文件夹显示设置的文件。 |
.Trash-* | 废纸篓在可移动介质或其他分区删除文件时生成的按用户区分的废纸篓目录(.Trash-1000)。 |
nohup.out | 后台运行日志用 nohup 运行命令时,输出默认写入的文件。 |
实践中的注意事项
*~规则在 Vim 模板中也有。同时选择两个模板时,去重选项会把它整理为一行。- 如果在服务器上有意保留
nohup日志,请重定向到其他名称(nohup cmd > run.log 2>&1 &)。 - 如果在 Linux 桌面上使用 JetBrains 或 VS Code,请同时选择相应的编辑器模板。
原始模板
Linux.gitignore
*~# temporary files which can be created if a process still has a handle open of a deleted file.fuse_hidden*# Metadata left by Dolphin file manager, which comes with KDE Plasma.directory# Linux trash folder which might appear on any partition or disk.Trash-*# .nfs files are created when an open file is removed but is still being accessed.nfs*# Log files created by default by the nohup commandnohup.out
模板来源: github/gitignore/Global/Linux.gitignore @356fd7b (2026-09-11) · CC0-1.0