Feature request: discard changes from selected files only
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
If I understood you correctly, resetting just the currently selected file in the commits view to HEAD?
Yes, that's correct (one or more files if multiple files are selected)
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).
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.
Yeah, the tooltip is probably sufficient -- it does list the affected files. The rewording could be useful, but certainly not essential.
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.
Just tried lazygit and was also confused by this. I had unstaged changes to a file and and staged new file change which I could not rest/unstage/restore that new file without completely discarding unstaged changes to the same file. Which option in lazygit does git restore --staged <file>?