Git Workflow in Neovim
These are real-world Git workflows executed entirely inside Neovim using Gitsigns + Neogit + Diffview.
Core Idea
The complete git workflow — write code → stage hunks → commit → push → review — can be done without leaving Neovim.
Workflow 1: Feature Branch Development
1. Create branch
<leader>gg → Open Neogit
b → c → Branch → Create new branch
Type: feature/auth-refactor
2. Write code in Neovim...
3. Review changes inline
]h / [h → navigate hunks (Gitsigns)
<leader>ghp → preview hunk in float
<leader>ghd → diff this file
4. Stage specific hunks (not whole files)
Navigate to hunk → <leader>ghs
5. Commit
<leader>gg → Neogit status
cc → Commit
Write message → <C-c><C-c> to confirm (or follow prompts)
6. Push
Pp → Push from Neogit
Workflow 2: Code Review (PR Diff)
1. Fetch remote branch
<leader>gg → Ff → Fetch
2. View diff vs main
:DiffviewOpen main..feature/auth-refactor
3. Navigate file by file
<Tab> → next file in Diffview
<S-Tab> → previous file
j/k → navigate in file list
4. View file history
<leader>gh → file history for current file
5. Leave comments (external, but jump back with marks)
mC → mark position
Open PR in browser
`C → return to marked position
Workflow 3: Hotfix (Amend + Push)
1. Make the fix
...edit the file...
2. Stage with gitsigns
<leader>ghs → stage the hunk
3. Amend the last commit
<leader>gg → Neogit
ca → Commit amend (reuse message)
4. Force push (if already pushed)
In Neogit: Pp → force push (careful!)
Workflow 4: Resolving Merge Conflicts
1. Pull causes conflict
:DiffviewOpen → opens 3-way merge view
2. Navigate conflicts
]x / [x → next/prev conflict marker
3. Resolve each conflict
<leader>co → accept ours
<leader>ct → accept theirs
(or manually edit the merged buffer)
4. Stage the resolved file
<leader>gg → s → stage resolved file
5. Complete the merge
cc → commit the merge
Useful Git Commands via Neovim Command Line
:!git log --oneline -20 → recent commits
:!git stash → stash changes
:!git stash pop → pop stash
:!git cherry-pick {hash} → cherry pick
:!git rebase -i HEAD~5 → interactive rebase
Telescope Git Integration
<leader>gc → browse git commits (Telescope)
<leader>gb → switch git branches (Telescope)
<leader>gs → git status files (Telescope)
Git Summary: What Tool Does What
| Tool | Does what |
|---|---|
| Gitsigns | Shows inline changed lines, stage/reset hunks |
| Neogit | Full status, stage, commit, push, branch |
| Diffview | Visual diff, file history, conflict resolution |
| Telescope | Browse commits, branches, status interactively |