git ignore vim temporary files

后端 未结 12 958
刺人心
刺人心 2020-12-12 08:38

What is the correct way to make git ignore temporary files produced by vim in all directories (either globally across the system or locally for a single project)?

12条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 09:25

    Vim temporary files end with ~ so you can add to the file .gitignore the line

    *~
    

    Vim also creates swap files that have the swp and swo extensions. to remove those use the lines:

    *.swp
    *.swo
    

    This will ignore all the vim temporary files in a single project

    If you want to do it globally, you can create a .gitignore file in your home (you can give it other name or location), and use the following command:

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

    Then you just need to add the files you want to ignore to that file

提交回复
热议问题