Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recursively create patch file using diff

Tags:

php

diff

I am on Linux, working on forking a PHP project. I want to create a patch file of the work that I have done, that can be applied to the latest parental code. Both original folder and new code folder are many subdirectories deep (so need recursive).

For some reason when I do :

diff -ur folder1 folder2 > newcode.patch

I don't manage to get the patch file including all of the new files, and it doesn't even contain some of the deeper file changes ( about 3+ levels deep).

Any ideas how to go about this? I've looked at Meld and Kdiff3...but they don't appear to do what I want either.

like image 499
Onyx Avatar asked Dec 27 '22 08:12

Onyx


1 Answers

I suspect you have a directory structure that's something like :

folder1/
  text.txt
  level1/
    text1.txt
    level2/
      text2.txt
      level3/
        text3.txt

folder2
  text.txt
  level1/
    text1.txt
    level2/
      text2.txt
      anewdirectory/
        newtext.txt
      level3/
        text3.txt
        newfiled3.txt

In this case, diff will ignore the file newtext.txt within anewdirectory/. It probably also doesn't pick up the text of newfiled3.txt either. Instead it reports something like :

..
Only in folder2/level1/level2/ : anewdirectory
Only in folder2/level1/level2/level3/ : newfiled3.txt
..

Is this the symptom you're seeing?
Try :

diff -urBNs folder1/ folder2/ > code.patch
like image 176
katyhuff Avatar answered Jan 12 '23 18:01

katyhuff