# vim-fugitive — Premier Git Plugin for Vim and Neovim > A comprehensive Git wrapper for Vim that lets you run any Git command from inside the editor, stage hunks interactively, browse history, resolve merge conflicts, and push code without leaving your buffer. ## Install Save in your project root: # vim-fugitive — Premier Git Plugin for Vim and Neovim ## Quick Use ```vim " Install with vim-plug Plug 'tpope/vim-fugitive' " Common commands inside Vim :Git status " open git status in a split :Git diff " view the current diff :Git commit " commit staged changes :Git blame " annotate the current file :Git push " push to remote ``` ## Introduction vim-fugitive, created by Tim Pope, is the most widely used Git integration plugin for Vim and Neovim. It wraps the entire Git CLI into Vim commands and buffers, so you can stage files, resolve conflicts, browse commit history, and push changes without switching to a terminal. It has been a staple of the Vim ecosystem for over a decade. ## What vim-fugitive Does - Provides `:Git` (or `:G`) as a general-purpose gateway to any Git subcommand from inside Vim - Opens an interactive status buffer where you can stage, unstage, and discard changes per hunk - Runs `:Git blame` with inline annotations and lets you press Enter to explore parent commits - Displays diffs in Vim buffers with full syntax highlighting and navigation - Supports three-way merge conflict resolution through `:Gdiffsplit` ## Architecture Overview vim-fugitive is a pure Vimscript plugin that communicates with Git through shell invocations. It intercepts Git output and renders it in custom Vim buffers with filetype-specific mappings. The status buffer uses autocmds and buffer-local keybindings to turn `s` into stage, `u` into unstage, and `=` into inline diff toggle. The `:GBrowse` command (via vim-rhubarb) constructs URLs for GitHub, GitLab, or Bitbucket. ## Self-Hosting & Configuration - Install via any Vim plugin manager: vim-plug, lazy.nvim, packer, or manual pathogen - No configuration is required; it works out of the box with any Git repository - Add `tpope/vim-rhubarb` for GitHub integration with `:GBrowse` - Customize statusline by adding `FugitiveStatusline()` to your `statusline` option - For Neovim users, fugitive is fully compatible and requires no special setup ## Key Features - Full Git CLI access through `:Git` without leaving the editor - Interactive staging and unstaging with per-hunk granularity in the status buffer - Inline blame annotations with commit navigation - Three-way diff split for merge conflict resolution - Seamless integration with Vim's quickfix list for `git grep` and `git log` results ## Comparison with Similar Tools - **Magit (Emacs)** — Similar philosophy but for Emacs; vim-fugitive is the Vim equivalent in popularity and scope - **Neogit** — A Magit-inspired Neovim plugin written in Lua; vim-fugitive is more mature and works in both Vim and Neovim - **Gitsigns.nvim** — Focuses on gutter signs and hunk actions; vim-fugitive covers the full Git workflow - **lazygit** — Terminal UI for Git; vim-fugitive keeps you inside the editor - **GitUI** — Rust-based terminal Git client; vim-fugitive integrates directly into the Vim editing workflow ## FAQ **Q: Does vim-fugitive work with Neovim?** A: Yes. It is fully compatible with Neovim and requires no additional configuration. **Q: How do I stage individual hunks?** A: Open `:Git` status, navigate to a file, press `=` to expand the diff inline, then use `s` on the hunk header to stage it. **Q: Can I use vim-fugitive with GitHub or GitLab?** A: Yes. Install vim-rhubarb (GitHub) or vim-flog and fugitive-gitlab (GitLab) to enable `:GBrowse` for opening files and commits in your browser. **Q: Is vim-fugitive slow on large repositories?** A: Performance depends on Git itself. For very large repos, operations like blame and log may take a moment, but fugitive adds minimal overhead. ## Sources - https://github.com/tpope/vim-fugitive - https://vimawesome.com/plugin/fugitive-vim --- Source: https://tokrepo.com/en/workflows/asset-544ccbc0 Author: AI Open Source