Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore files ending with ~ in git?

Tags:

git

In git-status, I have

sandbox.sh
sandbox.sh~

I would like to ignore the latter file.

How can you ignore files with extension of some snake ~?

like image 735
Léo Léopold Hertz 준영 Avatar asked Jul 13 '15 12:07

Léo Léopold Hertz 준영


2 Answers

Just add *~ to your .gitignore.

This will ignore all the files ending with ~

like image 168
pratZ Avatar answered Nov 09 '22 16:11

pratZ


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, i.e. ~/.config/git/ignore (create it if it does not exist) on recent enough versions of Git.

Alternatively, you can add it to your project's .gitignore file, but

1) It will add noise to the project's history. If N developers each use a different text editor with different conventions, you'll end-up with N lines in your .gitignore file.

2) You would have to do it for each project you contribute to.

like image 4
Matthieu Moy Avatar answered Nov 09 '22 17:11

Matthieu Moy