14

I want to stage a single line in SmartGit, rather than a whole diff hunk.

Eg:

old line
new line but leave unstaged
new line, just stage this
new line but leave unstaged
new line but leave unstaged
old line

This is doable with GitX on OS X but on SmartGit the smallest unit I appear to be able to stage is a whole set of diff lines.

joachim
  • 23,193
  • 11
  • 34
  • 41

2 Answers2

14

Use Local|Index Editor: you can edit the Index file content as you like there.

mstrap
  • 15,236
  • 6
  • 50
  • 77
  • How? I have the index editor open right now in front of me and I can see how to stage a *hunk* but not how to stage a single line. – joachim Aug 20 '12 at 19:18
  • 6
    Oh, I see. You have to actually select the line, copy from right RHS pane and click and paste it into the middle one. That's pretty lousy UI, as that's not actually staging a change but manually reproducing it in the index. – joachim Aug 21 '12 at 10:15
  • 4
    I agree. SourceTree has a "stage selected line(s)" function in the context menu of a single line. – Steven Roose Mar 06 '14 at 23:03
  • 1
    @StevenRoose, there is a much simpler procedure in more recent versions of SmartGit, see my updated answer. – mstrap Mar 07 '14 at 08:50
  • 2
    @mstrap I don't think the problem is how to use SmartGit's hunk features, but how to stage *part of* a hunk. SmartGit decides what a hunk is (basically any consecutive lines of new code) and there seems to be no way to override that if you only want part of that hunk for a commit. – neverfox Mar 30 '14 at 01:26
  • @neverfox, you are right -- I didn't reread the question carefully these 1.5 years later after my first answer. I changed the answer back. – mstrap Apr 04 '14 at 14:59
  • 3
    Awesome feature! Staging selected lines would be useful, though. – Mikhail Jan 13 '15 at 12:41
6

As of version 4.5 and later, you can simply select the file, and in Changes view, right click the line > Stage Hunk (OR) Stage Inner-line Changes (if you right click the highlighted change).

Jahan R-D
  • 126
  • 1
  • 7
  • 1
    It is missing in 17.1 if the older version is detected as binary (due to a long line), even if you press "force text" – JasonPlutext Feb 23 '18 at 21:47