how can I stage a single line in SmartGit?
Asked Answered
I

2

16

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.

Immortelle answered 2/8, 2012 at 15:46 Comment(1)
A
15

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

Amberambergris answered 2/8, 2012 at 15:52 Comment(7)
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.Immortelle
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.Immortelle
I agree. SourceTree has a "stage selected line(s)" function in the context menu of a single line.Airdrie
@StevenRoose, there is a much simpler procedure in more recent versions of SmartGit, see my updated answer.Amberambergris
@Amberambergris 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.Doomsday
@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.Amberambergris
Awesome feature! Staging selected lines would be useful, though.Tanhya
C
7

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).

Currier answered 18/4, 2016 at 3:43 Comment(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"Doublequick

© 2022 - 2024 — McMap. All rights reserved.