" requires vim-python and python-git
function! CommitFile()
python << EOF
import vim, git
curfile = vim.current.buffer.name
if curfile:
    try:
        repo = git.Repo(curfile)
        repo.git.add(curfile)
        repo.git.commit(m='Update')
    except (git.InvalidGitRepositoryError, git.GitCommandError):
        pass
EOF
endfunction
au BufWritePost * call CommitFile()