-
-
Couldn't load subscription status.
- Fork 2.3k
Description
Is your feature request related to a problem? Please describe.
I often find myself in situations where I've staged a bunch of files, then realize I actually want to commit the opposite set of changes first. Currently, the a key stages or unstages everything uniformly, but there's no way to invert/swap what's staged vs unstaged. Having to manually toggle each file with space gets tedious when dealing with many files.
Describe the solution you'd like
A keybinding that swaps the staging status of all files - everything currently staged becomes unstaged, and everything currently unstaged becomes staged. This would work in the Files panel on all files at once.
Describe alternatives you've considered
- Manually toggling each file with
space- works but tedious for many files - Using stash operations to indirectly achieve this - clunky workflow
- A custom command using git plumbing commands (
git write-tree,git apply, etc.) - possible but complex
Additional context
This is admittedly not a simple git operation (see [this Stack Overflow thread](https://stackoverflow.com/questions/3573410/what-is-the-shortest-way-to-swap-staged-and-unstaged-changes-in-git) for the gnarly git commands involved), but lazygit excels at making complicated git workflows simple, so it seems like a good candidate for a built-in feature.
I searched the existing issues and discussions and couldn't find any prior requests for this functionality (though there are related issues around stashing staged/unstaged changes separately #1863, #458. If lazygit already supports stashing staged or unstaged changes separately, this swap feature would make it easy to stash "the other half" of your changes - just invert staging and use the existing stash command.)