How do I delete "~" files permanently?

Every time I checkout a branch this happens:

M   src/note/views.py~
D   src/static/assets/css/inside.css~
D   src/templates/index.html~
D   src/templates/note/create.html~
D   src/templates/note/list.html~
D   src/templates/note/unite.html~

      

It's pretty annoying and makes me sick. How do I permanently delete these files?

+2


source to share


3 answers


You probably want to ignore them (these are backup files written by your editor). You have a file .gitignore

.

Actually .gitignore

this is the first file I add to the new new git

repo

So, edit .gitignore

to contain at least *~

a line (and maybe another line with *.o

if you have object files, etc.). Then



git add .gitignore

      

You can also delete these files, eg. with rm -vi **/*~

or rm -vi *~ */*~

(or use find

) - possibly also as answered by Chris Maes usinggit rm

+4


source


They probably shouldn't be versions at all. Use git rm

to remove them:

git rm src/note/views.py~

      



If you just don't want them to show up in git status, add them to .gitignore

as @basile suggests

+3


source


Following are the steps to delete files ~

and reuse this setting,

  • .gitignore only works with raw files, so it won't help with existing files ~

    . But you must add the following lines to the file .gitignore

    to avoid repeating this event.

    *~
    *.swp
    
          

  • now remove all ~

    files from your project with this command,

    find . -name "*~" -print | xargs rm
    
          

  • and then remove the files that have already been added to the git repository,

    git rm $(git ls-files --deleted)
    
          

and then commit your changes.

0


source







All Articles