lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Select working tree or index in diff mode

Open jckdn opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. There doesn't seem to be any way to produce diffs using the working tree or index in diff mode, such that enter can then be used to drill into changed file diffs. It seems only actual refs like HEAD can be chosen.

Such diffs are (I think) produced by git diff some-commit (working tree) git diff --cached some-commit (index).

Although I wonder if I'm missing some obvious option or workaround here since it seems a basic, and essential (for me anyway) feature.

Describe the solution you'd like To be able to select something like Working Tree or Index in the diff tool instead of a git ref.

Describe alternatives you've considered Committing all changes first and selecting HEAD as the ref. Doing something clever with Custom Command (not sure if possible).

jckdn avatar Apr 23 '23 12:04 jckdn

I don't think this would be very hard to implement. But I'm curious, since you say it's essential, and I have never needed it myself: can you describe a real-world scenario where you would use this?

stefanhaller avatar Apr 23 '23 13:04 stefanhaller

Maybe essential is an inaccurate term. I'm probably thinking this way simply because this kind of diff is the diff that is produced by default using the Compare References feature of my current daily driver for git - the GitLens extension in VSCode.

With GitLens' Compare References the first two options when it asks you to select refs are "Working Tree" and "HEAD", followed by a list of branches.

And somehow I regularly find myself in situations with changes in my working tree that I don't want to commit yet, but I still want to compare all my changes against dev branch, etc, to get a sense of the overall changes that my PR might contain, before I commit further, or undo changes, or maybe add more.

jckdn avatar Apr 23 '23 14:04 jckdn

It is very useful, I use this feature in Gitgraph vscode extension all the time. It provide final check and modifications before a PR. This way you can have full control of the changes of your PR

shan-weiqiang avatar May 09 '23 04:05 shan-weiqiang

I often need this when I want to do some cleanup and refactoring before sending my PR for review or just want to see all my changes while continuing working on the PR.

frixaco avatar Nov 16 '23 17:11 frixaco