Gitignore 星号代字号

Gitignore Asterisk Tilde

我有一个开源项目的 .gitignore 文件,其中包含以下行:

*~

.gitignore 文件的上下文中,这行 - 星号后跟波浪号 - 是什么意思?

我试过谷歌搜索但无济于事。

参见 https://git-scm.com/docs/gitignore 部分 "Pattern Format",在本例中:

If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).

所以它会忽略所有名称以波浪号结尾的文件。

它对 Git 没有特别的意义。它只会让 Git 对名称以波浪线

结尾的任何文件闭上眼睛

名称以波浪号结尾的文件可能是由原始程序员使用的某些软件创建的,例如文本编辑器,例如临时文件、备份文件或交换文件。您不希望它们显示在您的存储库中,因为它们与实际源代码无关。 例如,*~ 行与 Vim 用户添加的 .*.swp 行相同。