Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How can I create a patch that spans commits using Sourcetree?

I observe that when I "Create a patch", the dialog creates the patch that is "to" the commit I selected "from" it's predecessor.

In the dialog, I can tantalisingly select two separate commits and the diff panel shows the diffs that are between those two - that's the patch that I want.

But when I press "OK", I still get the single commit patch.

Is there some way to achieve what I meant.

5 answers

I'm seeing the same issue.

Interestingly, if I also select all the files in-between, I get these two DIFFERENT behaviors:

  • If I create ONE patch file, it is ONLY a combination of the first and the last commit
  • If I say create one file per commit, it creates patches for first, last and all in-between, as expected

I have not found a way from SourceTree to create a patch that does this (from the command line):

git diff <1st commit> <2nd commit> > patch.diff

even though the patch panel IS showing what I expect.

What I want: Developer A and Developer B have the same starting point of code.  Developer A does a bunch of work and has made many commits and is now at point X.  Developer A wants to email Developer B a patch file that will get Developer B from their common starting point to point X.

Yes, I could have Developer B clone the git repository, but I'm wanting a patch.  How do I do this?

I didn't get to see the content that was removed.

This problem remains for me (I got a reminder from the system asking me if this was resolved or not)

Is this still an issue?

I just use SourceTree Tools > Create Patch, then in dialog that opens, select all commits you want to be part of your patch.

I'm using 3.1 on Mac and I have this issue.

I accepted Steve's answer to close the question... at least it is supposed to behave the way one would expect ... if I come across the problem again I will re-raise.

Well - I have unaccepted Steve's answer to re-open this question.

The same problem exists, now in 1.9.2.

Appended is a screenshot showing it in action.

On the right is the patch creation dialog. You can see that I have selected two commits that are one commit apart. There are two (only) changes to the file, shown in the dialog, and there are also some changes to

On the left is the generate patch.diff. You can see that many more files have diffs for them in this patch (at the top) and you can see that more than two changes are being made to

All these extra changes are the changes that led _to_ the earlier of the two selected commits.

The fact that this generation process is fundamentally broken was confirmed when I selected "generate a separate patch file for each commit" in the patch creation dialog. There are only 2 commits between the source and destination that I am chosing, but three patch files were generated when I did this. The first of these contains the same "wrong" deltas - the deltas that led _to_ the earlier selected node.

patch generation problem

I'm observing the same behavior, the "Create patch..." shows what I want, but the resulting patch is wrong

0 votes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 24, 2012

When you select 2 lines, it actually shows you the diff *between* these two lines. To be consistent with this, that's the patch that's created, so if these commits are next to each other the difference is actually only the later commit (since the first is the base). Select a wider range to generate a patch for the difference of both commits.

I realise that may not be intuitive, there's a clash here between 'difference between two commits' and 'changes in selected commits'. Since the diff / log always works on the former this sheet also works on that basis.

Actually, this is exactly the behaviour that I was looking for. The display in the diff window is perfect.

Unfortunately, the same patch gets created whether I select one line or two: the "one line" patch.

Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 28, 2012

I just tested this, and I could create a patch with the range of commits just fine.

I need to be clear on my point: if you select 2 commits *next to each other*, then the patch created will be just the second commit. That's because a multiple selection is interpreted as "the difference between these two commits". If these commits are next to each other, then the difference between them is just the second commit, because difference is exclusive. For example:

Commit 4
Commit 3
Commit 2
Commit 1

If you select Commit 4 and create a patch, the diff will be Commit 4. If you select Commit 4 and Commit 3, the result will be the same, because the *difference* between them is still only Commit 4. To create a patch including the *changes* in Commit 3 and Commit 4, you have to select Commit 2 and Commit 4, since the difference is 3 and 4. I've tested this here and that's exactly what happens.

As I say, this may not be super-intuitive in the context of creating a patch, but it's consistent with the way multi-selection in the log happens elsewhere (to compare 2 points in history), and consistent with what shows in the diff.

Thanks very much for taking the time to prove to yourself that it works for you, and explain some gotchas.

As I've said, I think the we say that you describe it working makes perfect sense.

Unfortunately, this is not what it does for me. Please see the appended screenshot. You can see that I have selected three rows that end with product version 1.5.3. The diff in the sourcetree window shows what we would expect in the patch file. However, when I right click "create patch" everything looks the same in the "create patch" dialog (indicating we should expet success) but the resulting patch is shown in the editor on the side. You can see that the patch generated is the 1.5.2 Alpha single commit patch: it's the patch of the bottom-most selected row, only, as if the multiselect were not considered. I could also attach the patch-create window, but it looks the same...


Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 31, 2012

Hrm, I can't reproduce this - are you on the latest version of SourceTree (1.5.3)?

I'm now on 1.9.2, and I have the same issue (see below)

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events