jesseduffield / lazygit

simple terminal UI for git commands
MIT License
48.05k stars 1.73k forks source link

Feature request: discard changes from selected files only #3620

Open insane-dreamer opened 1 month ago

insane-dreamer commented 1 month ago

It would be nice to be able to discard changes from certain files only (the currently selected file(s) in the Commit panel, which are also displayed in the "Unstaged changes" panel)

when pressing d (discard), there could be an additional option to Discard changes from selected files

mark2185 commented 1 month ago

If I understood you correctly, resetting just the currently selected file in the commits view to HEAD?

insane-dreamer commented 1 month ago

Yes, that's correct (one or more files if multiple files are selected)

insane-dreamer commented 1 week ago

Actually, it turns out that this feature already exists. Select multiple files, press d and then select Discard all changes. I just didn't notice it because the wording sounds like it will discard all staged/unstaged changes, not just from the selected files. So maybe the only requested change would be to change the wording to Discard all changes from selected files (when one or more files are selected).

stefanhaller commented 1 week ago

We already have a pretty prominent tooltip telling you this, isn't that enough? Of course it's also easy to change the wording of the command like you suggest, I was just wondering.

insane-dreamer commented 1 week ago

Yeah, the tooltip is probably sufficient -- it does list the affected files. The rewording could be useful, but certainly not essential.

stefanhaller commented 1 week ago

I just realized that the real issue is probably that we only show the "Discard unstaged changes" item when a file with both unstaged and staged changes is selected; otherwise we only show the "Discard all changes" entry, and in that case it's not clear that "all" is meant in contrast to "unstaged", and not "all files in the working copy". I opened #3683 to improve that, if you want to have a look at that.