[英]How to ignore files ending with ~ in git?
In git-status, I have 在git-status中,我有
sandbox.sh
sandbox.sh~
I would like to ignore the latter file. 我想忽略后一个文件。
How can you ignore files with extension of some snake ~? 你怎么能忽略带有某些蛇〜的扩展名的文件?
Just add *~
to your .gitignore
. 只需将*~
添加到.gitignore
。
This will ignore all the files ending with ~
这将忽略所有以~
结尾的文件
The pattern to ignore anything ending with ~
is *~
. 忽略以~
结尾的任何内容的模式是*~
。 These files are probably left as backup by your text editor, hence are specific to you, and not to the project. 这些文件可能由文本编辑器保留为备份,因此特定于您,而不是项目。 The best is to add this *~
to your user-wide ignore file, ie ~/.config/git/ignore
(create it if it does not exist) on recent enough versions of Git. 最好的是将这个*~
添加到用户范围的忽略文件中,即~/.config/git/ignore
(如果它不存在则创建它)在最近的Git版本上。
Alternatively, you can add it to your project's .gitignore
file, but 或者,您可以将其添加到项目的.gitignore
文件中,但是
1) It will add noise to the project's history. 1)它会给项目的历史增加噪音。 If N developers each use a different text editor with different conventions, you'll end-up with N lines in your .gitignore
file. 如果N个开发人员各自使用具有不同约定的不同文本编辑器,则最终会在.gitignore
文件中使用N行。
2) You would have to do it for each project you contribute to. 2)您必须为您贡献的每个项目执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.