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

"This is not a valid patch file." for a patch file that I *just* created.

cdbarlow
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 18, 2018

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.

10 answers

7 votes
Kubilay Erdogan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2019

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.

Simon Salomons
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2019

You just saved me a full days work. Thank you!

Like Kubilay Erdogan likes this
Deniss Kaibagarovs
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 9, 2019

You are the best! 

4 votes
Emre Serbetcioglu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 10, 2019

I'm having the same issue. 

 

macOS Mojave(10.14.2)

 

SourceTree v 3.0.1 (205)

Omid Zamani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 11, 2019

same here.

Like Emre Serbetcioglu likes this
Sven Burkert
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 25, 2019

Same here. Patch created by SourceTree can be applied in console with "git apply".

Like David Corrie likes this
2 votes
Deniss Kaibagarovs
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 17, 2019

31843u.jpg

2 votes
Charlie McGeorge January 22, 2019

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.

1 vote
Greg Harrington
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 19, 2019

Does anyone know how to get SourceTree's attention on this bug?

0 votes
Charlie McGeorge June 24, 2019

Fixed in 3.2!

0 votes
gchaney May 16, 2019

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"

0 votes
Pierre-Yves Bertholon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 3, 2019

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.

0 votes
kobizz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 2, 2019

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)

0 votes
bgannin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2018

Hi Christopher,

What version of Sourcetree are you using? What platform are you on? 

Brian Ganninger
Senior Mac Developer, Sourcetree

Greg_Harrington
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 27, 2018

I am having the same issue. Version:

MacOS

3.0.1 (205)

dancorp0711
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 2, 2019

Same problem here too.  I had to roll back to 2.x to get patching to work.

jamesgosbell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 10, 2019

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)

DimitriC
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 11, 2019

I have the exact same issue. 

Mac OS

3.0.1 (205)

IhorZabrotsky
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 14, 2019

The same thing for me.

MacOS

v3.0.1 (205)

Toon Van de Putte January 22, 2019

I have the same issue. MacOS 10.13.3 and SourceTree 3.0.1 (205)

Kubilay Erdogan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 3, 2019

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.

Sagar Dagdu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 7, 2019

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.

Guy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 14, 2019

Same issue in 3.0.1...

MacOS Mojave 10.14.3

Kevin Prichard
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 18, 2019

Broken here as well, SourceTree 3.1.0, on macOS 10.14 (18A391), Darwin 18.0.0 kernel.

Max
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2019

Same issue - SourceTree 3.1 (210)

4np
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 3, 2019

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events