Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitignore Asterisk Tilde

Tags:

git

gitignore

I have a .gitignore file for an open source project that contains the following line:

*~

What does this line - an asterisk followed by a tilde - mean in the context of a .gitignore file?

I have tried Googling but to no avail.

like image 215
entpnerd Avatar asked Jan 06 '23 07:01

entpnerd


2 Answers

See https://git-scm.com/docs/gitignore section "Pattern Format", in this case:

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).

So it would ignore all files whos name ends with a tilde.

like image 120
Vampire Avatar answered Jan 08 '23 20:01

Vampire


It means nothing in particular to Git. It'll simply make Git close its eyes over any file which name ends with a tilde

Files with names ending with a tilde may be created by some software the original programmer has used, such as text editors, say temporary files, backup files or swap files for instance. You don't want those to show in your repository, as they are irrelevant to the actual source code. A *~ line is just the same as a .*.swp line added by a Vim user for instance.

like image 33
Mathias Dolidon Avatar answered Jan 08 '23 20:01

Mathias Dolidon