|
| 1 | +# Git Stack Manager (gitui) |
| 2 | + |
| 3 | +A simple Git TUI for managing branch stacks and complex branch trees. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This tool is designed to simplify the management of "stacked" branches, where |
| 8 | +multiple feature branches are built on top of each other. It provides a visual |
| 9 | +representation of the branch hierarchy and allows for easy restructuring of |
| 10 | +entire subtrees. |
| 11 | + |
| 12 | +## Key Features |
| 13 | + |
| 14 | +- **Visual Branch Tree:** Automatically detects and displays the relationship |
| 15 | + between local and remote branches. |
| 16 | +- **Interactive Move:** "Grab" a branch and move it to a new parent. The tool |
| 17 | + handles the rebase of the entire subtree. |
| 18 | +- **Predictive Conflict Detection:** Highlights potential merge conflicts |
| 19 | + *while* you are moving a branch, before any action is taken. |
| 20 | +- **Heuristic Repair (`u`):** Automatically detects when a branch has drifted |
| 21 | + from its true parent (e.g. after a remote rebase) and allows you to |
| 22 | + "converge" it back with a single keypress. |
| 23 | +- **Split Branch (`x`):** Interactively decompose a single commit into |
| 24 | + multiple sequential branches by selecting specific hunks. |
| 25 | +- **Remote Visibility:** Toggle between local-only and tracking views for |
| 26 | + `origin` and `upstream` remotes. |
| 27 | +- **Submit Workflow:** Plan and execute branch submissions to `upstream` with |
| 28 | + automatic sync to `origin`. |
| 29 | +- **Localize Remotes:** Easily create local tracking branches from remote |
| 30 | + branches by simply moving them in the tree. |
| 31 | +- **Branch Management:** Directly push (`p`), delete (`d`), reset (`r`), |
| 32 | + rename (`R`), or amend (`m`/`M`) branches from the TUI. |
| 33 | + |
| 34 | +## Shortcuts |
| 35 | + |
| 36 | +### Navigation |
| 37 | + |
| 38 | +- `j` / `Down`: Move selection down. |
| 39 | +- `k` / `Up`: Move selection up. |
| 40 | +- `a`: Toggle showing remote branches from `origin` and `upstream`. |
| 41 | + |
| 42 | +### Manipulation |
| 43 | + |
| 44 | +- `Space`: Grab or drop a branch. While grabbed, use `j`/`k` to select a new |
| 45 | + parent, or `h` to move to root. |
| 46 | +- `p`: Toggle pending push (for local branches with ahead commits). |
| 47 | +- `s`: Toggle pending submit (push to `upstream`, delete from `origin`, merge |
| 48 | + to `master`). |
| 49 | +- `x`: Enter Split Branch mode (only available if 1 commit ahead of parent). |
| 50 | +- `u`: Converge diverged branch (move to heuristic parent). |
| 51 | +- `d`: Toggle pending delete. |
| 52 | +- `r`: Toggle pending reset to upstream (or rebase onto upstream if |
| 53 | + ahead/behind). |
| 54 | +- `m`: Toggle pending amend (amends current staged changes into the selected |
| 55 | + branch). |
| 56 | +- `M`: Toggle pending amend with message update. |
| 57 | +- `R`: Rename the selected branch. |
| 58 | +- `f`: Toggle pending localize (for remote branches) or fetch (for root). |
| 59 | + |
| 60 | +### Execution |
| 61 | + |
| 62 | +- `v`: Enter Preview mode to see planned operations and predicted conflicts. |
| 63 | +- `c`: Execute all pending operations. |
| 64 | +- `Esc`: Cancel current grab or quit the current mode. |
| 65 | +- `q`: Quit. |
| 66 | + |
| 67 | +## CLI Usage |
| 68 | + |
| 69 | +```bash |
| 70 | +# Start the TUI in the current directory |
| 71 | +gitui |
| 72 | + |
| 73 | +# Start in a specific directory |
| 74 | +gitui --path /path/to/repo |
| 75 | + |
| 76 | +# Print the current tree and exit |
| 77 | +gitui --tree |
| 78 | + |
| 79 | +# Print the tree including remote branches |
| 80 | +gitui --tree --all |
| 81 | + |
| 82 | +# Show the submission plan for a branch and exit |
| 83 | +gitui --submit branch-name |
| 84 | + |
| 85 | +# Show the plan to fix a diverged branch (converge) |
| 86 | +gitui --converge branch-name |
| 87 | + |
| 88 | +# Show the plan to sync a branch with its upstream |
| 89 | +gitui --sync branch-name |
| 90 | +``` |
| 91 | + |
| 92 | +## Development |
| 93 | + |
| 94 | +This tool is built with: |
| 95 | + |
| 96 | +- **Language:** Rust |
| 97 | +- **UI:** [Ratatui](https://ratatui.rs/) |
| 98 | +- **Git Engine:** [git2-rs](https://github.com/rust-lang/git2-rs) |
| 99 | +- **Build System:** Bazel |
| 100 | + |
| 101 | +### Building |
| 102 | + |
| 103 | +```bash |
| 104 | +bazel build //hs-github-tools/tools/gitui:gitui |
| 105 | +``` |
| 106 | + |
| 107 | +### Testing |
| 108 | + |
| 109 | +```bash |
| 110 | +bazel test //hs-github-tools/tools/gitui/... |
| 111 | +``` |
0 commit comments