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

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!

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 1.6.11.0 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

546 views 1 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