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?
source to share
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
source to share
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.
source to share