How to commit changes to git server using vim editor

1 minute read

Published:

There are a couple of vim plugins for using git commands inside vim.

vim-fugitive

Once you installed this package, you can use git commands inside vim using commands such as :Git, :Gcommit, :Gstatus.

In typical usage, the workflow is as follows.

  • Creating a file and adding to the repository.
  • Modifying a file and committing changes to the repository.
  • Uploading updated files to the server.

For each tasks, we can use git commands in a terminal. But by using fugitive package, those tasks can be done as following.

  • :Gwrite to save file and add to a repository.
  • :Gstatus to see the modifications
  • :Gcommit to commit the changes. If you have multiple changes, you should put -a option.
  • :Gpush to upload to the server.

In vim, you can also find more help about vim-fugitive by typing :help fugitive. There are more commands that I listed above.

Currently, with neovim shows the following error message when you submit :Gcommit command. But the :Gcommit command seems working. And :Gpush does not show any messages.

Error detected while processing DirChanged Auto commands for "*":
E16: Invalid range: call rpcnotify(3, "python_chdir", v:event.cwd)

vim-gitgutter

This plugin shows line-by-line status of the file while you modify file. New lines have a + sign on the right column and modified lines have a ~ sign.

vimagit

I did not use it before and do not have much information.