Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to discard changes to individual lines of a file?

Edited

One of the main reasons I use SourceTree is the ability to commit changes to individual lines of a file, or discard those individual changes.

After upgrading to 2.6.10 on Windows 10 I can't seem to find this functionality anymore.

In the diff pane you used to be able to select multiple lines, right-click and select "Stage selected lines" or "Discard selected lines." Now right-clicking on a selected line in the diff pane just deselects the line.

Similar question from 2016, but the UI has changed since then, so the accepted answer does not apply to this version of SourceTree: https://community.atlassian.com/t5/Bitbucket-questions/What-if-you-don-t-want-to-stage-commit-part-of-the-quot-hunk/qaq-p/116026

1 answer

2 votes
minnsey Atlassian Team Oct 22, 2018

Hi

When you select 1 or more lines in the diff view the Stage HunkDiscard Hunk buttons in the upper right of the diff view should change to Stage Lines, Discard Lines

This functionality is so useful!

nymbus86 I'm New Here Nov 30, 2021

The problem is that when you scroll down within the diff view preview panel the Stage Lines / Discard Lines buttons become invisible. It would be best if you could have them fixed. I do understand that you can have more than one hunk per file (and even per multiple files selected), but I think you can still have those buttons visible while scrolling within the range of a hunk and have them slide up (or down) once the hunk from below (or above) reaches the top. I hope what I am saying is making sense.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published 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...

7,072 views 5 13
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you