Skip to content

Git: Add support for staging a subset of deleted lines #9475

Description

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.

Activity

  1. added
    bug
    git
    on Jul 19, 2016
  2. isidorn commented on Jul 25, 2016

    @isidorn
    Author

    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.

  3. kachkaev commented on Jul 25, 2016

    @kachkaev

    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.

  4. isidorn commented on Jul 25, 2016

    @isidorn
    Author

    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

  5. added
    feature-request
    and removed
    bug
    on Jul 25, 2016
  6. Dominik-K commented on Jun 26, 2018

    @Dominik-K

    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?

  7. 10 remaining items

  8. AgustinRamiroDiaz commented on Sep 7, 2022

    @AgustinRamiroDiaz

    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

  9. EmilStenstrom commented on Sep 7, 2022

    @EmilStenstrom

    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.

  10. mikkorantalainen commented on Oct 24, 2022

    @mikkorantalainen

    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!

  11. EmilStenstrom commented on Oct 24, 2022

    @EmilStenstrom

    Just for reference, this is what this looks like in Tower, a Mac client for Git:
    image

    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.

  12. MetRonnie commented on Mar 16, 2023

    @MetRonnie

    For reference (taken from desktop/desktop#1688 (comment)):

    GitHub Desktop screen capture

  13. pilgunboris commented on Aug 24, 2023

    @pilgunboris

    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.

  14. ADTC commented on Nov 10, 2023

    @ADTC

    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.

  15. davibe commented on Apr 24, 2024

    @davibe

    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.

  16. zachpoblete commented on Aug 9, 2024

    @zachpoblete

    Davide Bertola (@davibe) Yep, that bug is literally the most upvoted papercut; see #8226.

  17. zachpoblete commented on Aug 9, 2024

    @zachpoblete

    If anyone's wondering, #204221 mentioned this issue by mistake (which is why the PR description is edited).

  18. karahanyilmazer commented on Oct 23, 2024

    @karahanyilmazer

    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.

  19. changed the title [-]Git: Support line staging[/-] [+]Git: Add support for staging a subset of deleted lines[/+] on Dec 10, 2024
  20. llu025 commented on Feb 19, 2025

    @llu025

    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.

  21. MPLew-is commented on Feb 20, 2025

    @MPLew-is

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestgit

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions