Introduction
As developers, we often find ourselves working with Git in the terminal. While tools like VSCode or GUI-based Git clients offer file selection features, many developers prefer the simplicity and speed of the terminal.
Git also provides a built-in interactive mode with git add -i
. Have you ever tried using it? Personally, I didn’t find it particularly user-friendly.
There are powerful tools like fzf
or tig
that enhance terminal interactivity, but sometimes you just don't need all those advanced features. For me, having a lightweight tool to interactively select files for git add
and git stash
felt like the perfect solution.
When selection isn't possible, the typical workflow often involves running git status
, copying file names, and pasting them repeatedly for git add
or git stash
. This copy-paste process can be tedious and error-prone, especially in larger repositories.
To address this need, I wrote approximately 150 lines of code to create git-select-list
, a simple yet effective tool for developers seeking interactivity without complexity. You can find the repository here: git-select-list.
Features
-
Interactive UI: Navigate with arrow keys, select with
a
ors
, and toggle all withu
. -
Multiple Actions: Supports
git add
,git stash
,git stash apply
, andgit stash drop
. - Lightweight Setup: No external dependencies, with an included setup script.
Setup
1. Clone the repository
git clone https://github.com/pppp606/git-select-list.git
cd git-select-list
2. Run the setup script
bash setup.sh
3. After setup, you can use the git ls
command.
The setup script configures a convenient alias using Git's built-in alias
feature:
git config --global alias.ls '!sh $(pwd)/scripts/git-select-list.sh'
This alias allows you to execute the tool directly as git ls
, making it feel like a native Git command. If you haven’t explored Git’s alias functionality before, it’s a simple and powerful way to extend Git’s behavior without modifying your workflow.
Usage
Command Format
git ls <action> [subaction]
Supported Actions and Subactions
Command | Description |
---|---|
git ls add |
Interactively select modified files to stage. |
git ls stash |
Interactively select modified files to stash. |
git ls stash apply |
Interactively select stashes to apply. |
git ls stash drop |
Interactively select stashes to drop. |
Key Bindings
- Arrow Keys: Navigate between items.
-
a
ors
Key: Select or deselect the current item. -
u
Key: Select or deselect all items. -
Enter
Key: Confirm the selection. -
ESC
Key: Exit without making any changes.
Thanks for Checking It Out!
If you find git-select-list
useful, feel free to use it in your projects. And if you like it, consider starring the repository on GitHub—it would make my day!
📋 Git Select List
git-select-list
is a tool to interactively perform Git operations. It allows you to select files or stashes from a list for actions like git add
, git stash
, git stash apply
, and git stash drop
.
2025-01-11_20.29.54.mov
✨ Features
-
Interactive UI: Navigate with arrow keys, select with
a
ors
, and toggle all withu
. -
Multiple Actions: Supports
git add
,git stash
,git stash apply
, andgit stash drop
. - Lightweight Setup: No external dependencies, with an included setup script.
🔨 Setup
-
Clone this repository:
git clone https://github.com/pppp606/git-select-list.git cd git-select-list
-
Run the setup script:
bash setup.sh
-
After setup, you can use the
git ls
command.
💻 Usage
Command Format
git ls <action> [subaction]
Examples
Stage Files
- Run the following command
git ls add
- Select files from the displayed list using
a
oru
…
Update (2025/01/18)
After some reflection, I decided that the original git sl alias felt slightly unnatural. To make the command more intuitive, I’ve changed the default alias from git sl to git ls. All instances of sl in this article have been updated to ls.
If you’re already using the tool, feel free to set your own alias that works best for you!
Top comments (0)