Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell git to ignore files that start with a tilde?

Tags:

git

gitignore

My text editor creates swap files that start with a tilde. I accidentally checked on of these into git. How do I tell git to ignore any files like this anywhere in my project tree?

So I had

/folder/another/file.txt
/folder/another/~file.txt

I want ~file.txt to be ignored by git.

like image 507
Stephen Ostermiller Avatar asked Mar 25 '13 15:03

Stephen Ostermiller


2 Answers

Just use a .gitignore file:

echo '~*' >> .gitignore

Alternatively, you can also write this line to .git/info/exclude which is a project-wide local ignore file (which you obviously cannot check in, as you can do with .gitignore).

like image 150
bitmask Avatar answered Sep 20 '22 07:09

bitmask


echo '~*' >> .gitignore

This will append the needed entry.

Else edit the .gitignore file manually and add ~* on a new line.

like image 24
sjas Avatar answered Sep 18 '22 07:09

sjas