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 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, and toggle all with u.
This alias allows you to execute the tool directly as git sl, 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 sl <action> [subaction]
Supported Actions and Subactions
Command
Description
git sl add
Interactively select modified files to stage.
git sl stash
Interactively select modified files to stash.
git sl stash apply
Interactively select stashes to apply.
git sl stash drop
Interactively select stashes to drop.
Key Bindings
Arrow Keys: Navigate between items.
a 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 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, and toggle all with u.