Cannot stage truncated hunk

I have a file with a series of changes (11) . All of the the hunk buttons are enabled apart from the last one which is greyed out. Please can you explain why.


David Chilvers

4 answers

1 accepted

2 votes
Answer accepted

On windows, If you go to Tools->Options->Diff, there is a property "Max Diff Line Count",

Increasing cap to suit your needs will make Sourcetree show the entire diff, and ungrey the buttons.

Wow, that's handy. Thanks!

Thanks for that.

SourceTree limits how much of a diff it displays. If there are too many changes, SourceTree will eventually truncate the display in the middle of a hunk. It does not let you stage or discard that hunk because it is not showing you the entire hunk.

If you choose to stage or discard earlier hunks, it should reduce your diff content enough to display that entire hunk, which would let you use the buttons.

It's an annoying feature, but I assume it is necessary to keep SourceTree responsive when viewing large changesets.

EDIT: If your hunk is still too large, you can try highlighting large portions of it by clicking and shift-clicking within the large hunk, then staging or discarding "selected lines". I have never tried this in a partially displayed hunk, so I'm not sure if you'll be allowed or not.

BTW I am using Windows 7, SourceTree and git version 1.9.0.msysgit.0 Seth, I tried your suggestion but to no avail. The last hunk of about 500 lines, a pure insertion, still had the stage hunk button greyed out. 500 lines does not seem unduly large for a hunk. David

It may not be unduly large, but it appears to be larger that SourceTree is willing to handle. You can obviously choose to stage the entire file, or try to figure out how to stage hunks via command line. Other than that, I've updated my answer with a possible alternative.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,233 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you