GitUI

repository·master·Indexed 12 days ago

https://github.com/gitui-org/gitui

A high-performance, terminal-based Git GUI written in Rust. GitUI provides a responsive, keyboard-driven interface for common Git tasks including staging, committing, stashing, log browsing, and branch management, designed to remain fast even in very large repositories. Version 0.28.1.

Tokens
27.8K
Snippets
95
Records
143
Agent score
98%

What's inside GitUI

  1. Overview of GitUI Features

    master

    GitUI is a fast, terminal-based Git GUI designed for keyboard-only control. Key capabilities include:

    • Git Operations: Inspect, commit, amend, stage, unstage, revert, and reset files, hunks, and lines.
    • Branching & Remotes: Manage branch lists (create, rename, delete, checkout) and remotes (push/fetch).
    • Stashing: Save, pop, apply, drop, and inspect stashes.
    • Log & Diff: Browse and search commit logs and diff committed changes.
    • Advanced Support: Submodule support, async git API for fluid UI, and gpg commit signing (with known shortcomings).
  2. Overview of the filetreelist crate

    master
    The filetreelist crate is a component of the gitui project designed to manage lists of files visualized as a tree structure. It is specifically optimized for terminal user interfaces where efficient iteration over visible (non-collapsed) elements is required. The crate handles tree state transitions based on discrete inputs such as Up, Down, and Collapse, ensuring the visual representation remains consistent with the underlying data structure.
  3. What is asyncgit and how does it work?

    master

    The asyncgit crate is designed to allow using git2 (the Rust bindings for libgit2) within an asynchronous context.

    Its primary purpose is to prevent long-running Git operations from blocking the main thread, which is critical for keeping user interfaces (like gitui) responsive. It achieves this by offloading potentially heavy git2 calls onto a thread pool and using crossbeam-channel to notify the caller when an operation has completed.

    asyncgit is structured into two main parts:

    1. The main module: Provides the core asynchronous interface.
    2. The sync module: Provides convenience wrappers for common Git repository usage patterns.
  4. Use the watcher for faster change detection

    master

    By default, gitui uses a polling mechanism that checks for changes in the working directory every 5 seconds.

    If you want faster, event-driven updates, you can use the --watcher flag. This uses a notify-based approach instead of polling. Note that while faster, the notify approach may cause issues on certain platforms, which is why polling is the default.

    gitui --watcher
  5. Understand the scopetime log format

    master

    When a scope finishes, scopetime emits a log entry at the TRACE level. The log format includes the timestamp, log level, file location of the macro call, the measured duration, the scope name, and the source code location of the scope.

    Example log output: 19:45:00 [TRACE] (7) scopetime: [scopetime/src/lib.rs:34] scopetime: 2 ms [my_crate::foo] @my_crate/src/bar.rs:5

  6. Customize GitUI key bindings

    master

    GitUI allows you to fully customize key bindings by creating a key_bindings.ron file. The configuration uses the Ron file format.

    Each binding entry follows the pattern action_name: Some(( code: KeyCode, modifiers: "MODIFIERS")).

    Key Components

    • code: Uses KeyCode values from the crossterm crate (e.g., Char('h'), F(1)).
    • modifiers: Uses KeyModifiers values from crossterm (e.g., "SHIFT", "CTRL").

    File Locations

    Depending on your operating system, place the key_bindings.ron file in one of the following locations:

    • macOS: $HOME/.config/gitui/key_bindings.ron
    • Linux (XDG): $XDG_CONFIG_HOME/gitui/key_bindings.ron
    • Linux (Default): $HOME/.config/gitui/key_bindings.ron
    • Windows: %APPDATA%/gitui/key_bindings.ron
    (
        move_left: Some(( code: Char('h'), modifiers: "")),
        move_right: Some(( code: Char('l'), modifiers: "")),
        move_up: Some(( code: Char('k'), modifiers: "")),
        move_down: Some(( code: Char('j'), modifiers: "")),
    
        stash_open: Some(( code: Char('l'), modifiers: "")),
        open_help: Some(( code: F(1), modifiers: "")),
    
        status_reset_item: Some(( code: Char('U'), modifiers: "SHIFT")),
    )
  7. Customize UI key symbols

    master

    You can change how special keys (like enter or shift) are visually represented in the GitUI interface by creating a key_symbols.ron file. This file is loaded from the same configuration directories used for key bindings.

    Usage

    Provide a mapping of the symbol name to its desired string representation. If a symbol is not provided in the file, GitUI uses its defaults (e.g., for enter and for shift).

    File Locations

    • macOS: $HOME/.config/gitui/key_symbols.ron
    • Linux (XDG): $XDG_CONFIG_HOME/gitui/key_symbols.ron
    • Linux (Default): $HOME/.config/gitui/key_symbols.ron
    • Windows: %APPDATA%/gitui/key_symbols.ron
    (
        enter: Some("enter"),
        shift: Some("shift-")
    )
  8. Build GitUI with specific Cargo features

    master

    When building from source, you can manage features. The trace-libgit feature enables libgit2 tracing (requires libgit2 to be built with -DENABLE_TRACE=ON).

    By default, trace-libgit is enabled. To disable all default features and build a minimal version, use --no-default-features.

    # To disable default features (including trace-libgit)
    cargo install --no-default-features gitui
  9. Configure GitUI themes via theme.ron

    master

    To customize the colors of GitUI, create a theme.ron file in your configuration directory. Since version 0.23, you do not need to define the entire theme; you only need to specify the values you wish to override.

    Important: Because overrides are used, all values must be wrapped in Some().

    Configuration File Locations

    • macOS: $HOME/.config/gitui/theme.ron
    • Linux (XDG): $XDG_CONFIG_HOME/gitui/theme.ron
    • Linux (Default): $HOME/.config/gitui/theme.ron
    • Windows: %APPDATA%/gitui/theme.ron

    Using Custom Theme Files

    You can also load specific theme files using the -t flag. For example, gitui -t arc.ron will look for the file in your configuration directory (e.g., $HOME/.config/gitui/arc.ron).

    ( 
        selection_bg: Some("Blue"),
        selection_fg: Some("#ffffff"),
    )