git add -p <filename>
How do I do this in Git Extensions without having to drop to the command line? I can't seem to find a menu option or button that will do that from the Commit dialog.
Yes, that option is great but I really miss here "Stage/Unstage whole chunk" option that is available in git gui. If you have a lot of changes in a file selection on per-chunk basis is much more efficient.
Would it be possible to add such a feature?
Best
Mat
Thanks everyone for the tip on staging only some lines. This should get me by without having to drop to the command line. For further improvement, I think it’s worthwhile to break this down into 3 possible chunk-handling options:
· Staging only some lines/chunks
· Unstaging only some lines/chunks
· Resetting/discarding changes to only some lines/chunks
Each seems to have deficiencies/inconsistencies in how each is done in Git Extensions; I’ll address them below in a feature request:
· Staging only some lines: the “stage selected lines” feature as pointed out seems to work really well. The reason I did not find it is because there is no “Stage chunk of file” menu option next to the “Reset chunk of file” option when right-clicking the filename in the upper-left corner of the window. There needs to be:
o A new “Stage chunk of file” option when right-clicking the filename. When this is clicked, it will invoke the “git add -p" command for interactive staging in a console window – similar to “Reset chunk of file”.
o A new “Stage whole chunk” option when right-clicking a chunk in the text editor, just as Mateusz Pusz suggests.
· Unstaging only some lines:
o Again, there needs to be an “Unstage chunk of file” menu option when right-clicking a staged filename. Again, it would invoke “git reset -p” to interactively unstage in a console window.
o A new “Unstage whole chunk” option when right-clicking a chunk in the text editor, just as Mateusz Pusz suggests.
o (While I’m at it, there needs to be a menu to begin with when right-clicking a staged filename… similar to when right-clicking an unstaged file. For example, “View file history”, “Open With Difftool”, “Copy Filename” seem like some options that might be useful on staged files as well).
· Resetting only some lines. I assume the workflow should be that you must unstage first before resetting, i.e. permanently discarding changes to a file. (I assume this because the GUI currently offers no functional way to do this to any staged file – in whole or in part).
o A new “Reset whole chunk” option when right-clicking a chunk in the text editor when viewing a diff for an unstaged file; would be disabled if viewing a staged file.
o The “Reset selected line(s)” option when right-clicking in the text editor when viewing a diff for an unstaged file is disabled. It needs to be enabled in this scenario, just as the “Stage selected lines” option is enabled. Currently the only way to do this is to use the “Reset chunk of file” option and do it interactively in the console.
o The “Reset selected line(s)” option when right-clicking in the text editor when viewing a diff is enabled, but clicking it yields an error message. It really should be disabled in this scenario since you need to unstage first.
The end result I think would be much more consistent: right-click a filename to invoke console for interactive staging/unstaging/resetting. (Sometimes it’s nice to just be walked through this change-by-change). Select some lines and right-click them to stage/unstage/reset them. Or right-click a chunk to stage/unstage/reset it.
Should I start a new issue in the issue tracker for this? Any further thoughts on this?
James