junegunn/fzf-git.sh

bash, zsh, fish, and tmux bindings for Git objects, powered by fzf

Shell

1,193

100 commits

updated Sep 27, 2026

See the code

README

fzf-git.sh

bash, zsh, fish, and tmux key bindings for Git objects, powered by fzf.

image

Each binding will allow you to browse through Git objects of a certain type, and select the objects you want to paste to your command-line.

Installation

  • Install the latest version of fzf
    • (Optional) Install bat for syntax-highlighted file previews
    • Git v2.42.0 or later is required for the git for-each-ref binding
  • Update your shell configuration file

Usage

List of bindings

  • CTRL-G? to show this list
  • CTRL-GCTRL-F for Files
  • CTRL-GCTRL-B for Branches
  • CTRL-GCTRL-T for Tags
  • CTRL-GCTRL-R for Remotes
  • CTRL-GCTRL-H for commit Hashes
  • CTRL-GCTRL-S for Stashes
  • CTRL-GCTRL-L for reflogs
  • CTRL-GCTRL-W for Worktrees
  • CTRL-GCTRL-E for Each ref (git for-each-ref)

The Files binding works outside a git repository as well, where it falls back to the file search of fzf.

[!WARNING] You may have issues with these bindings in the following cases:

  • CTRL-GCTRL-B will not work if CTRL-B is used as the tmux prefix
  • CTRL-GCTRL-S will not work if flow control is enabled, CTRL-S will freeze the terminal instead
    • (stty -ixon will disable it)

To workaround the problems, you can use CTRL-G{key} instead of CTRL-GCTRL-{KEY}.

[!WARNING] If zsh's KEYTIMEOUT is too small (e.g. 1), you may not be able to hit two keys in time.

tmux bindings

The shell bindings are only available on the command-line, so they cannot be used when the pane is running another program. fzf-git.tmux binds the same list of commands to tmux keys, which work in any pane.

# ~/.tmux.conf
run-shell /path/to/fzf-git.tmux

fzf-git.tmux expects to find fzf-git.sh next to it, so keep the two files in the same directory.

The keys are the same as above, with PREFIXg in place of CTRL-G. So PREFIXgf is for Files, and PREFIXg? shows the list. Set @fzf-git-key to use a different key after the prefix key. The option is read when the bindings are created, so set it before run-shell.

set -g @fzf-git-key G
run-shell /path/to/fzf-git.tmux

fzf starts in a floating pane, in the working directory of the pane it was started from, and the selected objects are sent to that pane as if you typed them.

[!NOTE] A floating pane requires tmux 3.7 or later. On older versions, fzf starts in a popup instead.

[!NOTE] The finder does not load your shell configuration file, so _fzf_git_fzf redefined there has no effect. Use the tmux environment instead.

set-environment -g FZF_GIT_PAGER delta

[!TIP] tmux-fzf-complete completes into a pane the same way, for the things that are not Git objects: files, directories, and the URLs, paths, and sentences on the screen.

Inside fzf

  • TAB or SHIFT-TAB to select multiple objects
  • CTRL-/ to change preview window layout
  • CTRL-O to open the object in the web browser (in GitHub URL scheme)

Customization

# Redefine this function to change the options
_fzf_git_fzf() {
  fzf --height 50% --tmux 90%,70% \
    --layout reverse --multi --min-height 20+ \
    --no-separator --header-border horizontal \
    --border-label-pos 2 \
    --color 'label:blue' \
    --preview-window 'right,50%' --preview-border line \
    --bind 'ctrl-/:change-preview-window(down,50%|hidden|)' "$@"
}

Defining shortcut commands

Each binding is backed by _fzf_git_* function so you can do something like this in your shell configuration file.

gco() {
  _fzf_git_each_ref --no-multi | xargs git checkout
}

gswt() {
  cd "$(_fzf_git_worktrees --no-multi)"
}

Environment Variables

VariableDescriptionDefault
BAT_STYLESpecifies the style for displaying files using batfull
FZF_GIT_CATDefines the preview command used for displaying the filebat --style=$BAT_STYLE --color=$FZF_GIT_COLOR
FZF_GIT_COLORSet to never to suppress colors in the listalways
FZF_GIT_PAGERSpecifies the pager command for the preview window$(git config --get core.pager)
FZF_GIT_PREVIEW_COLORSet to never to suppress colors in the preview windowalways
bash
fish
fzf
tmux
zsh

junegunn/fzf-git.sh

bash, zsh, fish, and tmux bindings for Git objects, powered by fzf

Shell

1,193

100 commits

updated Sep 27, 2026

See the code

README

fzf-git.sh

bash, zsh, fish, and tmux key bindings for Git objects, powered by fzf.

image

Each binding will allow you to browse through Git objects of a certain type, and select the objects you want to paste to your command-line.

Installation

  • Install the latest version of fzf
    • (Optional) Install bat for syntax-highlighted file previews
    • Git v2.42.0 or later is required for the git for-each-ref binding
  • Update your shell configuration file

Usage

List of bindings

  • CTRL-G? to show this list
  • CTRL-GCTRL-F for Files
  • CTRL-GCTRL-B for Branches
  • CTRL-GCTRL-T for Tags
  • CTRL-GCTRL-R for Remotes
  • CTRL-GCTRL-H for commit Hashes
  • CTRL-GCTRL-S for Stashes
  • CTRL-GCTRL-L for reflogs
  • CTRL-GCTRL-W for Worktrees
  • CTRL-GCTRL-E for Each ref (git for-each-ref)

The Files binding works outside a git repository as well, where it falls back to the file search of fzf.

[!WARNING] You may have issues with these bindings in the following cases:

  • CTRL-GCTRL-B will not work if CTRL-B is used as the tmux prefix
  • CTRL-GCTRL-S will not work if flow control is enabled, CTRL-S will freeze the terminal instead
    • (stty -ixon will disable it)

To workaround the problems, you can use CTRL-G{key} instead of CTRL-GCTRL-{KEY}.

[!WARNING] If zsh's KEYTIMEOUT is too small (e.g. 1), you may not be able to hit two keys in time.

tmux bindings

The shell bindings are only available on the command-line, so they cannot be used when the pane is running another program. fzf-git.tmux binds the same list of commands to tmux keys, which work in any pane.

# ~/.tmux.conf
run-shell /path/to/fzf-git.tmux

fzf-git.tmux expects to find fzf-git.sh next to it, so keep the two files in the same directory.

The keys are the same as above, with PREFIXg in place of CTRL-G. So PREFIXgf is for Files, and PREFIXg? shows the list. Set @fzf-git-key to use a different key after the prefix key. The option is read when the bindings are created, so set it before run-shell.

set -g @fzf-git-key G
run-shell /path/to/fzf-git.tmux

fzf starts in a floating pane, in the working directory of the pane it was started from, and the selected objects are sent to that pane as if you typed them.

[!NOTE] A floating pane requires tmux 3.7 or later. On older versions, fzf starts in a popup instead.

[!NOTE] The finder does not load your shell configuration file, so _fzf_git_fzf redefined there has no effect. Use the tmux environment instead.

set-environment -g FZF_GIT_PAGER delta

[!TIP] tmux-fzf-complete completes into a pane the same way, for the things that are not Git objects: files, directories, and the URLs, paths, and sentences on the screen.

Inside fzf

  • TAB or SHIFT-TAB to select multiple objects
  • CTRL-/ to change preview window layout
  • CTRL-O to open the object in the web browser (in GitHub URL scheme)

Customization

# Redefine this function to change the options
_fzf_git_fzf() {
  fzf --height 50% --tmux 90%,70% \
    --layout reverse --multi --min-height 20+ \
    --no-separator --header-border horizontal \
    --border-label-pos 2 \
    --color 'label:blue' \
    --preview-window 'right,50%' --preview-border line \
    --bind 'ctrl-/:change-preview-window(down,50%|hidden|)' "$@"
}

Defining shortcut commands

Each binding is backed by _fzf_git_* function so you can do something like this in your shell configuration file.

gco() {
  _fzf_git_each_ref --no-multi | xargs git checkout
}

gswt() {
  cd "$(_fzf_git_worktrees --no-multi)"
}

Environment Variables

VariableDescriptionDefault
BAT_STYLESpecifies the style for displaying files using batfull
FZF_GIT_CATDefines the preview command used for displaying the filebat --style=$BAT_STYLE --color=$FZF_GIT_COLOR
FZF_GIT_COLORSet to never to suppress colors in the listalways
FZF_GIT_PAGERSpecifies the pager command for the preview window$(git config --get core.pager)
FZF_GIT_PREVIEW_COLORSet to never to suppress colors in the preview windowalways
bash
fish
fzf
tmux
zsh

Significant stargazers

(top 24 of 30)

Dongpo Liu

739 followers · starred Aug 2025

Jon Parise

385 followers · starred Aug 2022

Andreas Kohn

80 followers · starred Mar 2025

Blake Mizerany

1,542 followers · starred Sep 2024