6 ms·
I use IntelliJ IDEA and often rely on their own Git functionality. But it cannot stage specific lines, only whole chunks [1]. For that, I've been using lazygit
by FrontAid 3y ago
I use IntelliJ IDEA and often rely on their own Git functionality. But it cannot stage specific lines, only whole chunks [1]. For that, I've been using lazygit for a couple of months now. I like its simple UI and that it makes staging specific lines very easy and quick. If you like lazygit, you might also be interested in similar Git CLI clients that I collected here [2].
[1] https://youtrack.jetbrains.com/issue/IDEA-186988/Allow-commiting-only-specific-lines https://youtrack.jetbrains.com/issue/IDEA-186988/Allow-commi...
[2] https://github.com/frontaid/git-cli-tools#clients https://github.com/frontaid/git-cli-tools#clients
- tomkarho 3y agoIs this something missing specifically from IDEA? In Rider, there are features that allow committing individual lines instead of a whole file. You can select in the commit dialog which lines to include/omit. Also I recommended taking a look at Changelists feature that allows separating certain changes from what would be committed next (I believe it works line by line basis).
- FrontAid 3y agoI don't know Rider, but I assume this is a limitation in all of their IDEs. Yes, you can commit only certain changes within a file. But you can only do that based on whole chunks. For example, if you add two new lines at the end of an existing file, you cannot commit only one line but not the other. The same limitation applies to changelists (at least in IntelliJ IDEA and Webstorm).
- colejohnson66 3y agoDoesn't this come from git itself? If you try `git add -p <file>`, it'll chunk just as "bad".
- nerdponx 3y agoYou can edit the hunk manually. I believe it's also possible to construct a hunk to apply entirely from scratch as long as you get the header right.
- YellowSuB 3y agoYes, git generally stages just hunks with the patch add mechanism, but it is possible to stage single lines, but it is a bit tedious, see: https://kennyballou.com/blog/2015/10/art-manually-edit-hunks/index.html https://kennyballou.com/blog/2015/10/art-manually-edit-hunks...
- tomkarho 3y agoIndeed. That is a limitation with Rider too.
- deleted 3y ago[deleted]
- sugarpile 3y agoFWIW, the per line staging functionality in GitUp (https://gitup.co/ https://gitup.co/) is quite easy and straightforward. Very lightweight program that you can open via cli (`gitup` when in a git directory)
- hahn-kev 3y agoMacOS only
- CSSer 3y agoWow. VS Code can do that.
- jcurtis 3y agoUnless I'm misunderstanding your comment, this feature is actually included in the latest EAP/beta releases[1]. There is discussion of it at the bottom of the issue you linked. [1] https://blog.jetbrains.com/idea/2023/06/intellij-idea-2023-2-eap-5/#Optiontocommitspecificlinesofcode https://blog.jetbrains.com/idea/2023/06/intellij-idea-2023-2...
- FrontAid 3y agoYes, that's it. Judging from the screencast, I will continue using lazygit for that though. Not a fan of all the clicking. Hopefully there will be a keystroke available for it.