Forgit
:zzz: A utility tool powered by fzf for using git interactively.
Install / Use
/learn @wfxr/ForgitREADME
This tool is designed to help you use git more efficiently. It's lightweight and easy to use.
📝 Features
ga - Interactive git add selector:

glo - Interactive git log viewer:

gi - Interactive .gitignore generator:

Full Command List
| Command | Description |
|----------|-------------|
| ga | Interactive git add selector |
| gd | Interactive git diff viewer |
| gi | Interactive .gitignore generator |
| glo | Interactive git log viewer |
| gat | Interactive .gitattributes generator |
| gso | Interactive git show viewer |
| grh | Interactive git reset HEAD <file> selector |
| gcf | Interactive git checkout <file> selector |
| gcff | Interactive git checkout <file> from <commit> selector |
| gcb | Interactive git checkout <branch> selector |
| gsw | Interactive git switch <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 |
| gcp | Interactive git cherry-pick selector |
| grb | Interactive git rebase -i selector |
| grl | Interactive git reflog viewer |
| gbl | Interactive git blame selector |
| gfu | Interactive git commit --fixup && git rebase -i --autosquash selector |
| gsq | Interactive git commit --squash && git rebase -i --autosquash selector |
| grw | Interactive git commit --fixup=reword && git rebase -i --autosquash selector |
| gclean | Interactive git clean selector |
| gwt | Interactive git worktree selector |
| gwa | Interactive git worktree add selector |
| gwd | Interactive git worktree remove selector |
📥 Installation
Requirements
-
fzfversion0.49.0or higherIf your OS package manager bundles an older version of
fzf, you might install it usingfzf's own install script.
Shell Package Managers
# for zplug
zplug 'wfxr/forgit'
# for zgen
zgen load 'wfxr/forgit'
# for antigen
antigen bundle 'wfxr/forgit'
# for fisher (requires fisher v4.4.3 or higher)
fisher install wfxr/forgit
# for omf
omf install https://github.com/wfxr/forgit
# for zinit
zinit load wfxr/forgit
# for oh-my-zsh
git clone https://github.com/wfxr/forgit.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/forgit
# for sheldon.cli
[plugins.forgit]
github = "wfxr/forgit"
rev = "26.01.0" # check https://github.com/wfxr/forgit/releases for latest version
use = ["forgit.plugin.zsh"]
apply = ["source"]
# manually
# Clone the repository and source it in your shell's rc file or put bin/git-forgit into your $PATH
Homebrew
To install using brew
brew install forgit
Then add the following to your shell's config file:
# Fish:
# ~/.config/fish/config.fish:
[ -f $HOMEBREW_PREFIX/share/forgit/forgit.plugin.fish ]; and source $HOMEBREW_PREFIX/share/forgit/forgit.plugin.fish
# Zsh:
# ~/.zshrc:
[ -f $HOMEBREW_PREFIX/share/forgit/forgit.plugin.zsh ] && source $HOMEBREW_PREFIX/share/forgit/forgit.plugin.zsh
# Bash:
# ~/.bashrc:
[ -f $HOMEBREW_PREFIX/share/forgit/forgit.plugin.sh ] && source $HOMEBREW_PREFIX/share/forgit/forgit.plugin.sh
Arch User Repository
AUR packages, maintained by the developers of forgit, are available. Install the forgit package for the latest release or forgit-git to stay up to date with the latest commits from the default branch of this repository.
Completions
Forgit offers completions for all supported shells. Completions are automatically configured when installing forgit through Homebrew or the AUR. All other installation methods mentioned above require manual setup for completions. The necessary steps depend on the shell you use.
Bash
- Put
completions/git-forgit.bashin~/.local/share/bash-completion/completionsto have bash tab completion forgit forgitand configured git aliases. - Source
completions/git-forgit.bashexplicitly to have bash tab completion for forgit shell functions and aliases (e.g.,gsw <tab>completes branches).
Fish
- Put
completions/git-forgit.fishin~/.config/fish/completions/to have fish tab completion forgit forgitand configured git aliases, as well as shell command aliases, such asga.
Zsh
- Put
completions/_git-forgitin a directory in your$fpath(e.g.,/usr/share/zsh/site-functions) to have zsh tab completion forgit forgitand configured git aliases, as well as shell command aliases, such asforgit::addandga.
If you're having issues after updating, and commands such as forgit::add or aliases ga aren't working, remove your completions cache and restart your shell.
> rm ~/.zcompdump
> zsh
🚀 Usage
Shell Aliases
You can change the default aliases by defining these variables below before sourcing the forgit shell plugin.
(To disable all aliases, Set the FORGIT_NO_ALIASES flag.)
forgit_log=glo
forgit_reflog=grl
forgit_diff=gd
forgit_show=gso
forgit_add=ga
forgit_reset_head=grh
forgit_ignore=gi
forgit_attributes=gat
forgit_checkout_file=gcf
forgit_checkout_file_from_commit=gcff
forgit_checkout_branch=gcb
forgit_switch_branch=gsw
forgit_branch_delete=gbd
forgit_checkout_tag=gct
forgit_checkout_commit=gco
forgit_revert_commit=grc
forgit_clean=gclean
forgit_stash_show=gss
forgit_stash_push=gsp
forgit_cherry_pick=gcp
forgit_rebase=grb
forgit_blame=gbl
forgit_fixup=gfu
forgit_squash=gsq
forgit_reword=grw
forgit_worktree=gwt
forgit_worktree_add=gwa
forgit_worktree_delete=gwd
Git Integration
You can use forgit as a sub-command of git by making git-forgit available in $PATH:
# after `forgit` was loaded
PATH="$PATH:$FORGIT_INSTALL_DIR/bin"
Some plugin managers can help do this.
Then, any forgit command will be a sub-command of git:
git forgit log
git forgit add
git forgit diff
Optionally you can add aliases in git:
git config --global alias.cf 'forgit checkout_file'
And use forgit functions via a git alias:
git cf
⚙ Configuration
Options can be set via environment variables. They have to be exported in
order to be recognized by forgit.
For instance, if you want to order branches in gcb by the last committed date you could:
export FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS='--sort=-committerdate'
Per-command Options
Each forgit command can be customized with dedicated environment variables for git arguments and fzf options:
| Command | Git Options | FZF Options |
|----------|-------------|-------------|
| ga | FORGIT_ADD_GIT_OPTS | FORGIT_ADD_FZF_OPTS |
| glo | FORGIT_LOG_GIT_OPTS | FORGIT_LOG_FZF_OPTS |
| grl | FORGIT_REFLOG_GIT_OPTS | FORGIT_REFLOG_FZF_OPTS |
| gi | | FORGIT_IGNORE_FZF_OPTS |
| gat | | FORGIT_ATTRIBUTES_FZF_OPTS |
| gd | FORGIT_DIFF_GIT_OPTS | FORGIT_DIFF_FZF_OPTS |
| gso | FORGIT_SHOW_GIT_OPTS | FORGIT_SHOW_FZF_OPTS |
| grh | FORGIT_RESET_HEAD_GIT_OPTS | FORGIT_RESET_HEAD_FZF_OPTS |
| gcf | FORGIT_CHECKOUT_FILE_GIT_OPTS | FORGIT_CHECKOUT_FILE_FZF_OPTS |
| gcff | FORGIT_SHOW_GIT_OPTS<br>`FORGIT_CHECKOUT_FILE_GIT_OP
