:help viminfo-%
gives you some hints on how to achieve this:
Quickfix ('buftype'), unlisted ('buflisted'), unnamed and buffers on removable media (|viminfo-r|) are not saved.
I would simply make those files unlisted; as Vim is invoked from the version control system for the commit message, and usually no other files are edited within that session, the buffer listing (:ls
) and naviation (:bnext
) isn't particularly important there, anyway.
For COMMIT_EDITMSG
, you can hook into the existing filetype detection:
autocmd FileType gitcommit setlocal nobuflisted
or set up your own pattern(s):
autocmd BufNewFile,BufRead COMMIT_EDITMSG setlocal nobuflisted