DEV Community

mafflerbach
mafflerbach

Posted on

Fugitive - vim and git

vim-fugitive is the go-to git extension for VIM. I think there is no other git extension which is working so well.
Fugitive is not only a simple git wrapper, but it can act like, if its needed.

The most used mapping in my case are:


noremap <leader>ge :Gblame<CR>
noremap <leader>gs :Gstatus<CR>
noremap <leader>gc :Gcommit<CR>
noremap <leader>gl :Gpull<CR>
noremap <leader>gh :Gpush<CR>

Enter fullscreen mode Exit fullscreen mode

With Gstatus you get a git status of your current repository.

fungitive-git-status.png

If you want to stage a file. Use s or - for staging the file.
You can also stage all your file at once, if you are using s or - on the header Unstage.

If you want to unstage, us u on your item, or on the Stage header.

fungitive-git-status-2.png

If you want to see a diff, you go on the line of your changed file and hit = or i.

fungitive-git-status-3.png

If you want to open the file, hit Enter. The status buffer will stays, and the selected file will be open in a different buffer.

With Gcommit a additional split for your commit message will open. With save and close, the commit will be executed.

With Gpush your commit will be pushed to your remote.

In the case you have to revert you local changes, with Gread it will be performing a git checkout -- %

If you want to take a look on your git logs? No problem, fungitive is covering that too.
It will open your git log in a quickfix list, and it shows you what happened in previous commits.

fungitive-git-log.png

Top comments (0)