No matter what I do, it says:
This is not a valid patch file.
I just created a patch file from either a working copy or a commit using Create Patch yet it says that. I used to use patch files all the time for several years this way but now I can never get the Apply Patch to work.
So it turns out that it's not a bug but a feature(!). When it's not working copy, Sourcetree appends more info to the patch file (then it's not a patch file anymore...) so when I remove those information, the patch works fine.
For instance, here is the patch file Sourcetree creates from an old commit:
From 24e5d114c5809c3cad52f1c2ef693fa07b84cb7e Mon Sep 17 00:00:00 2001
From: Kubilay Erdogan <>
Date: Thu, 21 Feb 2019 15:42:23 +0100
Subject: [PATCH] Add todo.
---
project/Class.swift | 1 +
1 files changed, 1 insertions(+)
diff --git a/project/Class.swift b/project/Class.swift
index 00806946..742f52ef 100644
--- a/project/Class.swift
+++ b/project/Class.swift
@@ -335,6 +335,7 @@ extension Class {
case foo
// New definitions
+ // TODO: Create documentation for these
case bar
--
2.18.0
And I get "This is not a valid patch file" error when I try to apply the patch.
But if I remove the header and footer info (Text before the first `diff` and the last two lines (double dashes and version info(?)) then it works.
So the working patch file is:
diff --git a/project/Class.swift b/project/Class.swift
index 00806946..742f52ef 100644
--- a/project/Class.swift
+++ b/project/Class.swift
@@ -335,6 +335,7 @@ extension Class {
case foo
// New definitions
+ // TODO: Create documentation for these
case bar
Hope this helps someone.
You just saved me a full days work. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are the best!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having the same issue.
macOS Mojave(10.14.2)
SourceTree v 3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
same here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same here. Patch created by SourceTree can be applied in console with "git apply".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had the same issue on MacOS 10.14.2 and SourceTree 3.0.1 (205).
I downloaded SourceTree 3.0.0 (300) and the same issue was present there as well.
I downloaded SourceTree 2.7.4 (175) and the patch functionality worked fine. Patches generated by 2.7.4 and even patches generated by 3.0.0 were applied correctly. This would imply that the message "This is not a valid patch file" is actually incorrect and the bug is in the patch file parser, not the patch file generator. Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does anyone know how to get SourceTree's attention on this bug?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ran into same problem today several times. SourceTree 3.1.2 on a Mac.
My patch includes diff for four files.
I tried the suggestion above "remove the header and footer info (Text before the first `diff` and the last two lines (double dashes and version info(?))" . but the file still does not work, i still get "this is not a valid patch file"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've the issue in May 2019.
- Sourcetree Mac 3.1.2 (216).
- Use embedded Git 2.20.1.
- macOS Mojave (10.14.3)
The test to reproduce it:
- "Actions / Create Patch…". Save the patch file.
- "Actions / Apply Patch…". Select the previous created patch file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having the same issue. Just wondering how long it will take to the SourceTree team to 'apply a patch' and resolve that annoying bug.
SourceTree 3.0.1 (205) on macOS Mojave (10.14.4)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christopher,
What version of Sourcetree are you using? What platform are you on?
Brian Ganninger
Senior Mac Developer, Sourcetree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am having the same issue. Version:
MacOS
3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same problem here too. I had to roll back to 2.x to get patching to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also get this issue. I create a patch file the usual way through sourcetree but I can't apply it.
Mac OS
3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the exact same issue.
Mac OS
3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The same thing for me.
MacOS
v3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the same issue. MacOS 10.13.3 and SourceTree 3.0.1 (205)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue. Mojave, ST 3.0.1 (205)
Quite surprised that this has been going on for a while. I will try to downgrade to a version that actually works. Such a shame.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had the same issue on 3.1, downgraded to 2.7.4, and it is working fine. Seems to be a bug in the patch parser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue in 3.0.1...
MacOS Mojave 10.14.3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Broken here as well, SourceTree 3.1.0, on macOS 10.14 (18A391), Darwin 18.0.0 kernel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue - SourceTree 3.1 (210)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same here, SourceTree 3.1.1 (213) on macOS 10.14.4 Mojave using embedded Git 2.20.1. Switching over to System git (2.21.1) does not help.
If you remove the header from the patch file (e.g. the part up to the first diff statement) it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.