lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Add Config to make stashing to include untracked files automatically

Open sathishmanohar opened this issue 1 year ago • 3 comments

Right now default git stashing behavior doesn't include untracked files in the stash. I am annoyed by this most of the time. I create stash then undo it and then create a new one and include the stash with untracked files.

My proposed solution is to make a lazygit config when enabled the default stashing uses git stash -u rather than git stash essentially making stashing untracked files the default behavior.

I tried to make this behavior with .gitconfig but there is no git config option.

sathishmanohar avatar Jan 23 '24 17:01 sathishmanohar

I'm a bit torn about this. On the one hand I have had the wish often enough myself, so my initial reaction was: let's just use -u by default and not even provide a config to turn it off. But then, there are situations where you have untracked files that have no relation to the changes in your working copy (e.g. one-off bisect scripts, benchmark results, whatever), which you don't want to stash along with your changes. But then it's a case-by-case decision, for which a global config doesn't help. And for the case-by-case choice we have a UI already: just press 'a' to stage all files, this will include them in the stash.

So, I'm unsure, and I'd be interested in more opinions.

stefanhaller avatar Jan 24 '24 08:01 stefanhaller

I understand that there is a choice in the UI. a - Stage all changes does include the untracked files. U - Stash all changes including untracked files does this. I completely understand that this is a case by case choice which is why I'm not suggesting this to be default behavior. This is to help the workflow of those who stash all the untracked files a lot and wish it was a bit easier.

sathishmanohar avatar Jan 24 '24 09:01 sathishmanohar