vimtricks.wiki Concise Vim tricks, one at a time.

How do I view Git log with graph visualization inside Vim using fugitive?

Answer

:Git log --oneline --graph

Explanation

Tim Pope's vim-fugitive provides a complete Git interface inside Vim. The :Git command runs any Git command with output displayed in a Vim buffer, enabling full Git workflows without leaving the editor. The log view with graph shows branch history visually.

How it works

  • :Git log --oneline --graph — shows compact commit history with branch graph
  • :Git (no args) — opens interactive status window (stage, unstage, commit)
  • :Gdiffsplit — opens a vimdiff of the current file against the index
  • :GBrowse — opens the current file on GitHub in your browser

Example

:Git log --oneline --graph --all
* a1b2c3d (HEAD -> main) feat: add user auth
| * d4e5f6g (feature/api) wip: api routes
|/
* h7i8j9k fix: database connection
* k0l1m2n initial commit

Press <CR> on any commit to view it

Tips

  • In the :Git status window: - to stage/unstage, cc to commit, dd to diff
  • :Git stash and :Git stash pop work inline
  • :Gedit main:file.py opens a file from another branch
  • 0Gclog shows the full history of the current file in quickfix

Next

How do I return to normal mode from absolutely any mode in Vim?