lazygit
lazygit copied to clipboard
Add a way to copy text from the patch panel
Topic If I'm understanding it correctly, it's not currently possible to highlight a part of the patch while a commit is selected in the history log.
Your thoughts I think that would be useful when making searches in the codebase for where a change happened.
You can press Enter on a commit, select a file with Enter, highlight a part of the patch and press ctrl+p to open patch options, one of which is "copy to clipboard".
Does that help?
Pressing ctrl+p reports an error about the fact that the patch is empty, but I think it's referring to the "Custom Patch" panel. Pressing <space> copies the patch to the "Custom Patch" panel and I can then copy using ctrl+p but that copies all the patch instead of just a single line, so I find it a little bit clunky.
Press Enter on a file to open the file as a patch diff, and there you can add specific lines (with Space) into the Custom patch which you can then copy.
Check out this video for reference.
+1 to this, why I have to create some patch just to copy a few lines. Especially when user wants to select and copy the text from the unstaged, staged diff panels.
Is it difficult to enable yanking to clipboard for those? Can we help contributing this?
You can copy lines from the unstaged/staged panels, you just have to enter staging mode. You don't have to "create some patch" to do that, you just have to enter the mode where you would.
The reason is that only in staging mode do we have a selection that allows you to select which part of the patch to copy. Outside of those modes you can only scroll the view but not select lines.
You don't have to "create some patch" to do that, you just have to enter the mode where you would.
Ok, you can, but I failed to find the correct keybinding (: It's <c-o>. I was trying y or <C+c>. Any reasons why not y?
Also noticed that after update lazygit warns about hunk mode etc, but disabling it helps.
I also didn't mean to complain on patching logic, it works quite well, especially selecting "hunks" and generating custom patches, but it just feels complex for simple cases of "Oh I accidently removed this important 3 lines, I want to quickly open git diff, copy the lines and paste in my IDE". One could stash changes, copy relevant parts and pop the stash and paste, but it's like 3 context switches. Not mentioning selecting hunk for custom patch, copy the custom patch in clipboard (I cannot reverse it, it seems?) then apply etc.
Thanks for the lazygit OSS work! Trying to migrate off git gui.. 🙈
You don't have to "create some patch" to do that, you just have to enter the mode where you would.
Ok, you can, but I failed to find the correct keybinding (: It's
<c-o>. I was tryingyor<C+c>. Any reasons why noty?
<c-o> is the general keybinding to copy things in most of lazygit's views; I use it all the time in the commits panel to copy short hashes, or in the branches panel to copy branch names. It's good to have a standard shortcut for this that is the same in all views. As for why <c-o> was chosen for this, I don't know, that was before I joined the project.
Some views also support y, but that one opens a menu where you can choose different things to copy.
Also noticed that after update lazygit warns about hunk mode etc, but disabling it helps.
I would encourage you to not disable it; I strongly believe that the new default mode is better.
but it just feels complex for simple cases of "Oh I accidently removed this important 3 lines, I want to quickly open git diff, copy the lines and paste in my IDE".
If you are talking about staged or unstaged changes, you should look into the d shortcut for discarding hunks. That's much easier than copying/pasting things. If you are talking about changes that are already commited, I would still use lazygit to undo the change rather than copy/pasting; it's just a little bit more work, but still easier than doing it in the IDE. Just select the hunk in the custom patch editor, hit space to stage it, and then ctrl-p, d to discard it.
Wow, TIL the d on hunk, it's quite powerful, thanks!