Skip to content

Interactive fzf+git for Neovim. I remembered the git commands so you wont forget.

License

Notifications You must be signed in to change notification settings

ray-x/forgit.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[WIP] forgit.nvim

Interactive git commands with fzf.

An elevator pitch:

  • fzf + delta branches, commits, files, diffs, stashes, etc.
  • Get what you want in 2~5 keystrokes from cmd line?
  • Are you sure your 'p' key bind is pull or push? Your 'c' key bind is commit or checkout?
  • Do you stackoverflow the git commands e.g. rebase/stash/pick?
  • Do you feel the integration of git and your setup is not efficient enough?

Highlights

  • fzf the files you changed in your PR
  • fzf branches and diff with diff tools of your choice
  • search git (ref)log with fzf
  • pretty git graph
  • fzf stash with preview and pop stash
  • fzf hashes and diff tools of your choice
  • forgit by Wenxuan Zhang
  • git-fuzzy
  • 42 git commands alias
  • integrated with diffview.nvim
  • Wraps vim-fugitive commands
  • Up to 100 git commands / alias supported, e.g. Gfr for git fetch; git rebase

You need

  • install forgit
  • fzf so you can confirm/select the matches to apply your changes, also check fzf-vim-integration, as vim plugin and fzf README-VIM
    • Note: if you use linux e.g. arch, put this in your vimrc/init.lua
    set rtp+=/usr/share/vim/vimfiles
    runtime! plugin/fzf.vim
  • install git-fuzzy (optional)
  • by default the plugin using fd to list all files in the current folder, you can use git ls_file
  • a diff pager, e.g. delta
  • vim-fugitive (highly recommended)
  • Windows user need to install bash e.g. git bash and forgit. You may need to put git-forgit to your PATH.
forgit.mp4

install

Plug 'ray-x/guihua.lua'  "lua GUI lib
Plug 'ray-x/forgit.nvim'

Configure

require'forgit'.setup({
  debug = false, -- enable debug logging default path is ~/.cache/nvim/forgit.log
  diff_pager = 'delta', -- you can use `diff`, `diff-so-fancy`
  diff_cmd = '', -- you can use `DiffviewOpen`, `Gvdiffsplit` or `!git diff`, auto if not set
  fugitive = false, -- git fugitive installed?
  abbreviate = false, -- abvreviate some of the commands e.g. gps -> git push
  git_alias = true,  -- git command extensions see: Git command alias
  show_result = 'quickfix', -- show cmd result in quickfix or notify

  shell_mode = true, -- set to true if you using zsh/bash and can not run forgit commands
  height_ratio = 0.6, -- height ratio of floating window when split horizontally
  width_ratio = 0.6, -- width ratio of floating window when split vertically
  cmds_list = {} -- additional commands to show in Forgit command list
  --  e.g. cmd_list = {text = 'Gs get_hunks', cmd = 'Gitsigns get_hunks'}
})

Screenshot

ga

gbd

usage

  • forgit commands supported by this plugin
Command Action
Ga{!} Interactive git add generator, bang! will unstage files
Glo Interactive git log generator
Gi Interactive .gitignore generator
Gd Interactive git diff viewer
Grh Interactive git reset HEAD <file> selector
Gcf Interactive git checkout <file> selector
Gcb Interactive git checkout <branch> selector
Gbd Interactive git branch -D <branch> selector
Gct Interactive git checkout <tag> selector
Gco Interactive git checkout <commit> selector
Grc Interactive git revert <commit> selector
Gss Interactive git stash viewer
Gsp Interactive git stash push selector
Gclean Interactive git clean selector
Gcp Interactive git cherry-pick selector
Grb Interactive git rebase -i selector
Gbl Interactive git blame selector
Gfu Interactive git commit --fixup && git rebase -i --autosquash selector
  • git + fzf commands supported only by this plugin
Command Action
Gac Interactive git add generator, if file staged, run 'git commit'
Gfz run git fuzzy, sub commands supports, e.g. Gfz status
Gbc Interactive git branch && checkout generator
Gbc! Interactive git branch -r && checkout generator
Gde Interactive git diff --name-only & edit selected file generator
Gde! Interactive git diff master/main --name-only & edit selected file generator
Gdd Interactive git diff --name-only & OpendiffView selected file generator
Gdd! Interactive git diff master/main --name-only & DiffviewOpen generator
Gbc Interactive git branch --sort=-committerdate && checkout generator, The preview is graphic view of git log
Gdc Interactive git log commit_hash & show diff against current & checkout generator
Gldt Interactive git log commit_hash & difftool hash of selected filename generator
Gldt! Interactive git log commit_hash & difftool hash of all files generator
Gbdo Interactive git branch & DiffviewOpen selected branch with diffview.nvim generator
Gldo Interactive git log commit_hash & DiffviewOpen current file with diffview.nvim generator
Gldo! Interactive git log commit_hash & DiffviewOpen all diff files with diffview.nvim generator
Grlg Interactive git rev-list & git grep generator

⌨ Forgit Keybinds

Key Action
Enter Confirm
Tab Toggle mark and move up
Shift - Tab Toggle mark and move down
? Toggle preview window
Alt - W Toggle preview wrap
Ctrl - S Toggle sort
Ctrl - R Toggle selection
Ctrl - Y Copy commit hash*
Ctrl - K / P Selection move up
Ctrl - J / N Selection move down
Alt - K / P Preview move up
Alt - J / N Preview move down

⌨ Git command alias

Command Action
Gaa git add --all
Gap git add -pu
Gash git stash
Gasha git stash apply
Gashp git stash pop
Gashu git stash --include-untracked
Gau git add -u
Gbs git bisect
Gbsb git bisect bad
Gbsg git bisect good
Gbsr git bisect reset
Gbss git bisect start
Gc git commit, if -m not specify, will prompt a ui.input
Gce git clean
Gcef git clean -fd
Gcl git clone
Gdf git diff --
Gdnw git diff -w --
Gdw git diff --word-diff
Gdmn git diff master/main --name-only | fzf
Gdn git diff --name-only | fzf
Gf git fetch
Gfa git fetch --all
Gfr git fetch; and git rebase
Glg git log --graph --decorate
Gm git merge
Gmff git merge --ff
Gmnff git merge --no-ff
Gopen git config --get remote.origin.url
Gpl git pull
Gplr git pull --rebase
Gpla git pull --autostash
Gps git push
Gpsf git push --force-with-lease
Gr git remote -v
Grb git rebase
Grbi git rebase -i
Grbc git rebase --continue
Grba git rebase --abort
Grs git reset --
Grsh git reset --hard
Grsl git reset HEAD~
Gs git status
Gsh git show
Gt git tag
Gtop git rev-parse --show-toplevel
Gurl git config --get remote.origin.url

🍱 All in One: Forgit command

forgit

forgit-search-for-gitsigns

Forgit command allows you to list all commands in a floating windows and you can fuzzy search and run any command you want.

  • vim-fugitive commands
  • forgit commands
  • forgit.nvim commands (acronym)
  • vim-flog commands
  • gitsigns commands

📦 Optional dependencies

About

Interactive fzf+git for Neovim. I remembered the git commands so you wont forget.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages