How to access the text in the diff view of sourcetree?

Sometimes I want to patch the staged file with deleted texts. It would be convenient if I can select and copy them.

3 answers

1 accepted

If I understand your question correctly, you want to copy-paste text from a staged file using the diff view of SourceTree into another file or from a file into the staged file.

To copy from the diff view, simply select the text in the view and do a ctrl-C / ⌘-C and ctrl-V / ⌘-V it anywhere.

The copy command is also available from a right-click context menu once you have selected the text in the diff view. 

As for modifying the staged file, you should probably be editing it in your primary editor. It will be updated and re-staged after you've saved the file in that editor and SourceTree senses the change.

Thanks. The shortcuts works, though it only copies one entire line.

Because selecting in diff view is lame, it cannot choose just words or multiple lines.

Also, right-click context menu cannot appear in diff view.

Where can I issue a ticket for those function?

On Windows, you can select multiple lines, but selecting words or using right-click are not possible.

Thanks, It's not dragging to select, but with shift. Now I see.

But it is kind of buggy. If you select a line and click the lines under it with shift, that works fine, But clicking upward is weird, which will unselect your previous selection and select next line.

Yep. That's all you've got to work with in the built-in diff.

I agree, it feels buggy and incomplete. It's not consistent between Windows and Mac platforms either, except for shortcut keys. FWIW, I typically use FileMerge on Mac and WinMerge on Windows for external diff tools. If I need a selective merge those are my tools of choice.

Right-click in diff view works on Mac but not on Windows. Clearly, a difference in behaviors between the platforms.

To report these issues, use Help | Report bug... in Windows; Help | Open a ticket on JIRA in Mac version. They're using their own tools to manage their bug list. 

In my experience Eric, i've yet to use the diff view in the manner you propose, I've always selected whole lines or blocks at a time for copy-paste and never tried spanning them or ctrl-select them. I'm either pulling whole commits or finding a change block to do a quick copy-paste from one project into another and never needed much else. It's not what the tool is about, IMHO. I'd still support your reporting it as a bug, especially the lack of context menu on Windows version. 

You can use the git command line, or lunch the external diff tool from Sourcetree.

What program do you have configured as your external diff tool?

I can select a file and press cmd+D to have the selected and previous versions open in my text editor side by side in diff mode.

For older versions I can right click the file and "open selected version" to open the file at the state it was in for that commit.

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

542 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