.gitignore does not ignore my temporary vim files

I have problems with the .gitignore file. I did my research and tried many methods. The following steps are performed when I save .gitignore

git rm -rf --cached *.php.* git add . git status git commmit -m "some message" 

This is what my .gitignore file looks like:

 # Ignores anything that a temp file created by vim .*.s?? .*.*.s?? 

Here are the files he needs to track from tracking

 # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .ajax.php.swn # .ajax.php.swo # .ajax.php.swp # .swervepay.php.swn # .swervepay.php.swo # .swervepay.php.swp # .swervepay_form.php.swm # .swervepay_form.php.swn # .swervepay_form.php.swp 

What can I do to save these files using gettin? Every time I add git. and commit to push, these files are added again. Any help would be helpful.

+6
source share
1 answer

Use standard rules

There is a convenient github repository for ignoring rules , for Vim the rules ::

 # swap [._]*.s[aw][az] [._]s[aw][az] # session Session.vim # temporary .netrwhist *~ # auto-generated tag files tags 

The best way to use these rules is to put them in your global git ignore file :

 git config --global core.excludesfile ~/.gitignore 

Or put your swap files somewhere else

However, it will probably be better:

 " ~/.vimrc file " swap files (.swp) in a common location " // means use the file full path set dir=~/.vim/_swap// " backup files (~) in a common location if possible set backup set backupdir=~/.vim/_backup/,~/tmp,. " turn on undo files, put them in a common location set undofile set undodir=~/.vim/_undo/ 

Thus, vim will not pollute your working copies with files, ignore or not =).

+23
source

Source: https://habr.com/ru/post/969404/


All Articles