Convert Figma logo to code with AI

wfxr logoforgit

:zzz: A utility tool powered by fzf for using git interactively.

4,577
141
4,577
15

Top Related Projects

67,278

:cherry_blossom: A command-line fuzzy finder

36,887

A simple, fast and user-friendly alternative to 'find'

49,894

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

15,600

An interactive cheatsheet tool for the command-line

55,342

simple terminal UI for git commands

38,009

GitHub’s official command line tool

Quick Overview

forgit is a utility tool that enhances Git usage through interactive command-line interfaces. It provides a set of fuzzy-finder powered Git commands, allowing users to interactively stage, unstage, view logs, and perform other Git operations with ease.

Pros

  • Improves Git workflow efficiency with interactive interfaces
  • Integrates seamlessly with popular fuzzy finders like fzf
  • Customizable with various configuration options
  • Supports multiple shells including bash, zsh, and fish

Cons

  • Requires additional dependencies (e.g., fzf, bat)
  • May have a learning curve for users accustomed to traditional Git commands
  • Some features might not work on all operating systems or Git versions

Getting Started

To install forgit, you can use your preferred package manager or clone the repository:

# Using git
git clone https://github.com/wfxr/forgit.git ~/.forgit

# Add the following line to your shell configuration file (.bashrc, .zshrc, etc.)
source ~/.forgit/forgit.plugin.zsh

# Or, if you're using a plugin manager like Oh My Zsh, add forgit to your plugins:
plugins=(... forgit)

After installation, you can start using forgit commands. For example:

  • ga for interactive git add
  • glo for interactive git log
  • gd for interactive git diff

Customize forgit by setting environment variables in your shell configuration file:

export FORGIT_FZF_DEFAULT_OPTS="--exact"
export FORGIT_ADD_FZF_OPTS="--reverse"

For more detailed instructions and configuration options, refer to the project's README on GitHub.

Competitor Comparisons

67,278

:cherry_blossom: A command-line fuzzy finder

Pros of fzf

  • More versatile, can be used for general-purpose fuzzy finding beyond Git operations
  • Highly customizable with extensive options and configurations
  • Faster performance, especially for large datasets

Cons of fzf

  • Requires more setup and configuration for Git-specific workflows
  • Less intuitive for Git operations out of the box
  • Steeper learning curve for Git-related tasks

Code Comparison

fzf (general-purpose fuzzy finding):

find * -type f | fzf > selected

forgit (Git-specific fuzzy finding):

forgit::log

Key Differences

  • Scope: fzf is a general-purpose fuzzy finder, while forgit is specifically tailored for Git operations
  • Ease of use: forgit provides pre-configured Git commands, making it easier to use for Git workflows
  • Flexibility: fzf offers more flexibility for custom integrations and non-Git use cases
  • Performance: fzf generally performs faster, especially with large datasets
  • Integration: forgit integrates seamlessly with Git, while fzf requires additional setup for Git-specific tasks

Both tools have their strengths, with fzf excelling in versatility and performance, and forgit offering a more streamlined experience for Git operations. The choice between them depends on the user's specific needs and workflow preferences.

36,887

A simple, fast and user-friendly alternative to 'find'

Pros of fd

  • Written in Rust, offering better performance and memory safety
  • Provides a simpler, more user-friendly syntax compared to traditional find command
  • Supports colored output and parallel command execution

Cons of fd

  • Limited to file and directory search, lacking git-specific functionality
  • Requires installation of a separate binary, not a shell script like forgit
  • May not integrate as seamlessly with existing git workflows

Code Comparison

fd:

fd -e txt
fd '^x.*rc$'
fd -e rs -x wc -l

forgit:

forgit::log
forgit::add
forgit::diff

Summary

fd is a fast and user-friendly alternative to the find command, focusing on file and directory search with improved performance. forgit, on the other hand, is a utility that enhances git commands with interactive fuzzy-finding capabilities. While fd excels in general file searching tasks, forgit is specifically tailored for git operations, making it more suitable for developers working extensively with git repositories.

49,894

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Pros of ripgrep

  • Faster and more efficient search capabilities, especially for large codebases
  • Supports various file types and encoding formats out of the box
  • Highly customizable with numerous command-line options

Cons of ripgrep

  • Focused solely on searching, lacking git-specific functionality
  • Steeper learning curve for users unfamiliar with command-line tools
  • May require additional setup for integration with git workflows

Code Comparison

ripgrep:

rg -i 'pattern' --type=rust

forgit:

forgit::log

Key Differences

ripgrep is a powerful search tool designed for speed and efficiency, while forgit is a collection of git utilities that enhance the git command-line experience. ripgrep excels at searching through large codebases quickly, whereas forgit focuses on simplifying git operations and providing interactive interfaces for common git tasks.

ripgrep is more versatile for general text searching across various file types, while forgit is specifically tailored for git-related operations. Users looking for advanced search capabilities might prefer ripgrep, while those seeking to streamline their git workflow would benefit more from forgit.

In terms of integration, ripgrep can be used alongside git but requires additional setup, whereas forgit is designed to work seamlessly with git out of the box. The learning curve for ripgrep might be steeper for some users, but it offers more fine-grained control over search parameters.

15,600

An interactive cheatsheet tool for the command-line

Pros of navi

  • Broader scope: Supports multiple shells and command-line tools, not just Git
  • Interactive cheatsheet functionality for quick command lookup and execution
  • Extensible with custom cheatsheets and integrations

Cons of navi

  • Steeper learning curve due to more complex functionality
  • Requires manual setup of cheatsheets for optimal use
  • May be overkill for users primarily focused on Git operations

Code Comparison

navi:

navi --query "git commit"

forgit:

forgit::add

Key Differences

  • Purpose: navi is a general-purpose command-line helper, while forgit focuses specifically on enhancing Git workflows
  • User Interface: navi uses an interactive TUI for browsing and selecting commands, forgit relies more on fzf for fuzzy finding
  • Customization: navi allows for creating custom cheatsheets, forgit primarily extends existing Git commands

Use Cases

  • Choose navi for a comprehensive command-line assistant across multiple tools and shells
  • Opt for forgit if you're primarily looking to streamline Git operations with minimal setup

Community and Development

Both projects are actively maintained open-source repositories on GitHub, with forgit having a slightly larger user base due to its focused Git functionality.

55,342

simple terminal UI for git commands

Pros of lazygit

  • Full-featured TUI application with interactive menus and keyboard shortcuts
  • Provides a comprehensive Git workflow management interface
  • Supports advanced features like interactive rebase and submodule management

Cons of lazygit

  • Requires installation as a separate binary
  • Steeper learning curve due to more complex interface
  • May be overkill for users who prefer simpler, command-line based interactions

Code comparison

lazygit (Go):

func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
    message := gui.trimmedContent(v)
    if message == "" {
        return gui.createErrorPanel(gui.Tr.NoCommitMessageErr)
    }
    return gui.handleCommitSubmit(message)
}

forgit (Shell):

fga() {
    git ls-files -m -o --exclude-standard | fzf -m --preview 'git diff --color=always {}' | xargs -I{} git add {}
}

lazygit offers a more comprehensive Git management solution with a full TUI, while forgit provides lightweight, fzf-based enhancements to existing Git commands. lazygit is better suited for users who prefer a graphical interface and need advanced Git features, while forgit is ideal for those who want to enhance their command-line Git workflow without leaving the terminal.

38,009

GitHub’s official command line tool

Pros of cli

  • Official GitHub CLI tool with comprehensive GitHub integration
  • Supports a wide range of GitHub operations beyond git commands
  • Regular updates and maintenance from GitHub's development team

Cons of cli

  • Larger installation size and potentially more resource-intensive
  • Focused on GitHub-specific features, less emphasis on local git operations
  • Steeper learning curve for users primarily interested in git functionality

Code comparison

forgit:

# Interactive git add selector
ga() {
    git add -p $(forgit::ignore | fzf -m --ansi --preview="git diff --color=always -- {}")
}

cli:

# Create a pull request
gh pr create --title "Fix bug in user authentication" --body "This PR addresses the issue with..."

Summary

forgit is a lightweight tool that enhances git commands with interactive features, while cli is a comprehensive GitHub CLI tool. forgit focuses on improving local git workflows, whereas cli provides a complete set of GitHub-related operations. Choose forgit for a streamlined git experience or cli for full GitHub integration.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

💤 forgit

Utility tool for using git interactively. Powered by junegunn/fzf.

pre-commit Contributors

This tool is designed to help you use git more efficiently. It's lightweight and easy to use.

📥 Installation

Requirements

  • fzf version 0.49.0 or higher

    If your OS package manager bundles an older version of fzf, you might install it using fzf'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

# 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.

📝 Features

  • Interactive git add selector (ga)

screenshot

  • Interactive git log viewer (glo)

screenshot

The log graph can be disabled by option FORGIT_LOG_GRAPH_ENABLE (see discuss in issue #71).

  • Interactive .gitignore generator (gi)

screenshot

  • Interactive git diff viewer (gd)

  • Interactive git show viewer (gso)

  • Interactive git reset HEAD <file> selector (grh)

  • Interactive git checkout <file> selector (gcf)

  • Interactive git checkout <branch> selector (gcb)

  • Interactive git branch -D <branch> selector (gbd)

  • Interactive git checkout <tag> selector (gct)

  • Interactive git checkout <commit> selector (gco)

  • Interactive git revert <commit> selector (grc)

  • Interactive git stash viewer (gss)

  • Interactive git stash push selector (gsp)

  • Interactive git clean selector (gclean)

  • Interactive git cherry-pick selector (gcp)

  • Interactive git rebase -i selector (grb)

  • Interactive git reflog viewer (grl)

  • Interactive git blame selector (gbl)

  • Interactive git commit --fixup && git rebase -i --autosquash selector (gfu)

⌨ Keybindings

KeyAction
EnterConfirm
TabToggle mark and move down
Shift - TabToggle mark and move up
?Toggle preview window
Alt - WToggle preview wrap
Ctrl - SToggle sort
Ctrl - RToggle selection
Ctrl - YCopy commit hash/stash ID*
Ctrl - K / PSelection move up
Ctrl - J / NSelection move down
Alt - K / PPreview move up
Alt - J / NPreview move down
Alt - EOpen file in default editor (when possible)

* Available when the selection contains a commit hash or a stash ID. For Linux users FORGIT_COPY_CMD should be set to make copy work. Example: FORGIT_COPY_CMD='xclip -selection clipboard'.

⚙ Options

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'

shell aliases

You can change the default aliases by defining these variables below. (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_branch=gcb
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

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

git options

If you want to customize git's behavior within forgit there is a dedicated variable for each forgit command. These are passed to the according git calls.

CommandOption
gaFORGIT_ADD_GIT_OPTS
gloFORGIT_LOG_GIT_OPTS
grlFORGIT_REFLOG_GIT_OPTS
gdFORGIT_DIFF_GIT_OPTS
gsoFORGIT_SHOW_GIT_OPTS
grhFORGIT_RESET_HEAD_GIT_OPTS
gcfFORGIT_CHECKOUT_FILE_GIT_OPTS
gcbFORGIT_CHECKOUT_BRANCH_GIT_OPTS, FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS
gbdFORGIT_BRANCH_DELETE_GIT_OPTS
gctFORGIT_CHECKOUT_TAG_GIT_OPTS
gcoFORGIT_CHECKOUT_COMMIT_GIT_OPTS
grcFORGIT_REVERT_COMMIT_GIT_OPTS
gssFORGIT_STASH_SHOW_GIT_OPTS
gspFORGIT_STASH_PUSH_GIT_OPTS
gcleanFORGIT_CLEAN_GIT_OPTS
grbFORGIT_REBASE_GIT_OPTS
gblFORGIT_BLAME_GIT_OPTS
gfuFORGIT_FIXUP_GIT_OPTS
gcpFORGIT_CHERRY_PICK_GIT_OPTS

pagers

Forgit will use the default configured pager from git (core.pager, pager.show, pager.diff) but can be altered with the following environment variables:

Use caseOptionFallbacks to
common pagerFORGIT_PAGERgit config core.pager or cat
pager on git showFORGIT_SHOW_PAGERgit config pager.show or $FORGIT_PAGER
pager on git diffFORGIT_DIFF_PAGERgit config pager.diff or $FORGIT_PAGER
pager on git blameFORGIT_BLAME_PAGERgit config pager.blame or $FORGIT_PAGER
pager on gitignoreFORGIT_IGNORE_PAGERbat -l gitignore --color always or cat
pager on gitatrributesFORGIT_ATTRIBUTES_PAGERbat -l gitattributes --color always or cat
git log formatFORGIT_GLO_FORMAT%C(auto)%h%d %s %C(black)%C(bold)%cr%reset

fzf options

You can add default fzf options for forgit, including keybindings, layout, etc. (No need to repeat the options already defined in FZF_DEFAULT_OPTS)

export FORGIT_FZF_DEFAULT_OPTS="
--exact
--border
--cycle
--reverse
--height '80%'
"

Customizing fzf options for each command individually is also supported:

CommandOption
gaFORGIT_ADD_FZF_OPTS
gloFORGIT_LOG_FZF_OPTS
grlFORGIT_REFLOG_FZF_OPTS
giFORGIT_IGNORE_FZF_OPTS
gatFORGIT_ATTRIBUTES_FZF_OPTS
gdFORGIT_DIFF_FZF_OPTS
gsoFORGIT_SHOW_FZF_OPTS
grhFORGIT_RESET_HEAD_FZF_OPTS
gcfFORGIT_CHECKOUT_FILE_FZF_OPTS
gcbFORGIT_CHECKOUT_BRANCH_FZF_OPTS
gbdFORGIT_BRANCH_DELETE_FZF_OPTS
gctFORGIT_CHECKOUT_TAG_FZF_OPTS
gcoFORGIT_CHECKOUT_COMMIT_FZF_OPTS
grcFORGIT_REVERT_COMMIT_FZF_OPTS
gssFORGIT_STASH_FZF_OPTS
gspFORGIT_STASH_PUSH_FZF_OPTS
gcleanFORGIT_CLEAN_FZF_OPTS
grbFORGIT_REBASE_FZF_OPTS
gblFORGIT_BLAME_FZF_OPTS
gfuFORGIT_FIXUP_FZF_OPTS
gcpFORGIT_CHERRY_PICK_FZF_OPTS

Complete loading order of fzf options is:

  1. FZF_DEFAULT_OPTS (fzf global)
  2. FORGIT_FZF_DEFAULT_OPTS (forgit global)
  3. FORGIT_CMD_FZF_OPTS (command specific)

Examples:

  • ctrl-d to drop the selected stash but do not quit fzf (gss specific).
export FORGIT_STASH_FZF_OPTS='
--bind="ctrl-d:reload(git stash drop $(cut -d: -f1 <<<{}) 1>/dev/null && git stash list)"
'
  • ctrl-e to view the logs in a vim buffer (glo specific).
export FORGIT_LOG_FZF_OPTS='
--bind="ctrl-e:execute(echo {} |grep -Eo [a-f0-9]+ |head -1 |xargs git show |vim -)"
'

other options

OptionDescriptionDefault
FORGIT_LOG_FORMATgit log format%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset
FORGIT_PREVIEW_CONTEXTlines of diff context in preview mode3
FORGIT_FULLSCREEN_CONTEXTlines of diff context in full-screen mode10
FORGIT_DIR_VIEWcommand used to preview directoriestree if available, otherwise find

📦 Optional dependencies

  • delta / diff-so-fancy: For better human-readable diffs.

  • bat: Syntax highlighting for gitignore and gitattributes.

  • emoji-cli: Emoji support for git log.

  • tree: Directory tree view for gclean.

Completions

Bash

  • Put completions/git-forgit.bash in ~/.local/share/bash-completion/completions to have bash tab completion for git forgit and configured git aliases.
  • Source completions/git-forgit.bash explicitly to have bash tab completion for forgit shell functions and aliases (e.g., gcb <tab> completes branches).

Zsh

  • Put completions/_git-forgit in a directory in your $fpath (e.g., /usr/share/zsh/site-functions) to have zsh tab completion for git forgit and configured git aliases, as well as shell command aliases, such as forgit::add and ga

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

💡 Tips

  • Most of the commands accept optional arguments (e.g., glo develop, glo f738479..188a849b -- main.go, gco main).
  • gd supports specifying revision(e.g., gd HEAD~, gd v1.0 README.md).
  • Call gi or gat with arguments to get the wanted .gitignore/.gitattributes contents directly(e.g., gi cmake c++).

📃 License

MIT (c) Wenxuan Zhang