You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Git: Add support for staging a subset of deleted lines #9475
From Alexander Kachkaev (@kachkaev)
I can't find out how to select just two deleted lines out of 5 going sequentially and stage only the ones I want. Any time I select something and click that menu item, the whole block gets staged. The same happens when unstaging.
Reacted by Dominik K., Morris Allison III, Ralf Vogler, Abigail O'Rourke, Chris Bandy, Alexander, Mathieu M-Gosselin, Jan Voráček, Alejandro García Iglesias, Jordan Tucker and 44 more
Unfortunetly this can not be supported with the current ux design. Namely, a diff editor does not support selecting deleted lines thus it is impossible for the user to specify which deleted lines to stage.
Closing as will not fix.
Why is the issue closed? Should not it stay open until the UX design is changed? Staging line-by-line is a pretty basic and pretty demanded feature, which I've seen in all git GUIs I've used.
Reacted by Alejandro García Iglesias, Andy Earnshaw, George Varghese M., Felix von Drigalski, Moritz Maxeiner, criptych, Ricardo Graça, Emil Stenström, Mikko Rantalainen, Jean-Philippe Robin and 6 more
Sure, we can reopen this and keep it as a feature request to be able to stage deleted lines one by one. PRs are welcome
Reacted by Alexander Kachkaev, Eric Amodio, Dominik K., Nathan A. Ferch, Misa Jovanovic, Mathieu M-Gosselin, Philippe, Alejandro García Iglesias, Andy Earnshaw, Aliaksei Kislou and 5 more
Emil Stenström (@EmilStenstrom) You can select only deleted lines by selecting before and after where the lines would be. One thing that I wasn't able to do though was to select line by line from the deleted block
You are right: Selecting deleted lines that are surrounded by untouched code works. But selecting individual lines is not possible, and you can't add a deleted line if you've also added lines before or after that you don't want to include.
The only UI that makes sense here is being able to pick lines (deleted or not) you want to add.
Reacted by Agustín Díaz, Paul Tirk, Mikko Rantalainen, Borys Pylhun, Andrey Filipenkov and NeuralTron
I cannot believe that "git gui" is still the state-of-art GUI even today when I want to commit logical lines instead of files. Hopefully this gets fixed. I'd be very happy with literally simple reimplementation of git gui interface. If I could get syntax highlighting to work while selecting lines to add or remove, I'd be very happy!
Just for reference, this is what this looks like in Tower, a Mac client for Git:
You click in the margin to select a line, and clicking Stage Lines at the top right stages only those line. You can click either deleted or added lines.
The absence of this ability in vscode is the only reason I have to use an extra git GUI tool to rewrite commits history before opening something for code review.
I hope this can be implemented soon.
Reacted by M1ker1n, Armin Nabavi, the0neWhoKnocks, Alex Roy, Karahan Yılmazer and Aleksandr Aksarin
If I right-click the deleted line, I get a small context menu with options like the following: (I also get this context menu by clicking the little bulb icon on the left, although this is currently blocked by regression #197743.)
Copy deleted lines
Copy deleted line (number)
Revert this change
It would be a start to add "Stage deleted line (number)" or "Unstage deleted line (number)" here (depending on context).
Also, if I consecutively right-click two lines within the same deleted diff block, the context menu could have an additional option to work on that range between the two lines (inclusive): "Stage deleted lines (first line number-last line number)" (or "Unstage ...").
Once this simple menu option is added and released, fancier UI can be explored in a later release for the easier staging of multiple lines.
Contrary to what was stated above, I am able to select one or more deleted lines using the split view (by disabling the inline diff view). In that situation, trying to stage the selected 'range' does nothing.
Similarly I can select the added lines alone, but then staging them also stages the removed ones within the same git hunk.
This is a bug, not a ux design limitation or choice.
I am also interested in this feature as I find myself staging and deleting individual lines quite often. "Stage selected ranges" doesn't do the trick for me all the time. I would very much appreciate having this functionality in my workflow.
Has there been any update on this? Still dealing with the same issue both in inline view and side-by-side view: deleted lines are "accessible" for selection and staging only if surrounded by unchanged lines, they must be staged in block all at once (cannot be split into two commits), and they are forced to be staged together with any adiacent added lines if the latter are staged.
It seems pretty clear that this either isn't a priority or requires overhauling some key pieces of code that would be painful enough that it's not worth it. I recommend a standalone Git client (I like Fork on macOS) or moving to another editor like Zed.
Activity
isidorn commentedon Jul 25, 2016
Unfortunetly this can not be supported with the current ux design. Namely, a diff editor does not support selecting deleted lines thus it is impossible for the user to specify which deleted lines to stage.
Closing as will not fix.
kachkaev commentedon Jul 25, 2016
Why is the issue closed? Should not it stay open until the UX design is changed? Staging line-by-line is a pretty basic and pretty demanded feature, which I've seen in all git GUIs I've used.
isidorn commentedon Jul 25, 2016
Sure, we can reopen this and keep it as a feature request to be able to stage deleted lines one by one. PRs are welcome
Dominik-K commentedon Jun 26, 2018
Isidor Nikolic (@isidorn) João Moreno (@joaomoreno) Why is it designed to disable right hand side staging?
Selecting the deleted lines in the right hand side would solve this issue. Would this be easy to code?
10 remaining items
AgustinRamiroDiaz commentedon Sep 7, 2022
Emil Stenström (@EmilStenstrom) You can select only deleted lines by selecting before and after where the lines would be. One thing that I wasn't able to do though was to select line by line from the deleted block
I've made a quick demo: https://www.loom.com/share/86ab3fb5f3e24c3c9d3fc2651e8d7c72
EmilStenstrom commentedon Sep 7, 2022
You are right: Selecting deleted lines that are surrounded by untouched code works. But selecting individual lines is not possible, and you can't add a deleted line if you've also added lines before or after that you don't want to include.
The only UI that makes sense here is being able to pick lines (deleted or not) you want to add.
mikkorantalainen commentedon Oct 24, 2022
I cannot believe that "git gui" is still the state-of-art GUI even today when I want to commit logical lines instead of files. Hopefully this gets fixed. I'd be very happy with literally simple reimplementation of git gui interface. If I could get syntax highlighting to work while selecting lines to add or remove, I'd be very happy!
EmilStenstrom commentedon Oct 24, 2022
Just for reference, this is what this looks like in Tower, a Mac client for Git:

You click in the margin to select a line, and clicking Stage Lines at the top right stages only those line. You can click either deleted or added lines.
MetRonnie commentedon Mar 16, 2023
For reference (taken from desktop/desktop#1688 (comment)):
pilgunboris commentedon Aug 24, 2023
The absence of this ability in vscode is the only reason I have to use an extra git GUI tool to rewrite commits history before opening something for code review.
I hope this can be implemented soon.
ADTC commentedon Nov 10, 2023
If I right-click the deleted line, I get a small context menu with options like the following: (I also get this context menu by clicking the little bulb icon on the left, although this is currently blocked by regression #197743.)
It would be a start to add "Stage deleted line (number)" or "Unstage deleted line (number)" here (depending on context).
Also, if I consecutively right-click two lines within the same deleted diff block, the context menu could have an additional option to work on that range between the two lines (inclusive): "Stage deleted lines (first line number-last line number)" (or "Unstage ...").
Once this simple menu option is added and released, fancier UI can be explored in a later release for the easier staging of multiple lines.
davibe commentedon Apr 24, 2024
Contrary to what was stated above, I am able to select one or more deleted lines using the split view (by disabling the inline diff view). In that situation, trying to stage the selected 'range' does nothing.
Similarly I can select the added lines alone, but then staging them also stages the removed ones within the same git hunk.
This is a bug, not a ux design limitation or choice.
zachpoblete commentedon Aug 9, 2024
Davide Bertola (@davibe) Yep, that bug is literally the most upvoted papercut; see #8226.
zachpoblete commentedon Aug 9, 2024
If anyone's wondering, #204221 mentioned this issue by mistake (which is why the PR description is edited).
karahanyilmazer commentedon Oct 23, 2024
I am also interested in this feature as I find myself staging and deleting individual lines quite often. "Stage selected ranges" doesn't do the trick for me all the time. I would very much appreciate having this functionality in my workflow.
[-]Git: Support line staging[/-][+]Git: Add support for staging a subset of deleted lines[/+]llu025 commentedon Feb 19, 2025
Has there been any update on this? Still dealing with the same issue both in inline view and side-by-side view: deleted lines are "accessible" for selection and staging only if surrounded by unchanged lines, they must be staged in block all at once (cannot be split into two commits), and they are forced to be staged together with any adiacent added lines if the latter are staged.
MPLew-is commentedon Feb 20, 2025
It seems pretty clear that this either isn't a priority or requires overhauling some key pieces of code that would be painful enough that it's not worth it. I recommend a standalone Git client (I like Fork on macOS) or moving to another editor like Zed.