Last active
May 26, 2023 22:54
-
-
Save nttan/4cb72437d7e55f1963313af546821912 to your computer and use it in GitHub Desktop.
Magento 2 - Create composer patch without git commit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I use this method for creating patch, hope it helps . Let suppose you will modify this file | |
| vendor/magento/module-customer/Block/CustomerData.php | |
| Create a copy of that file whith your changes on it : | |
| vendor/magento/module-customer/Block/CustomerDataModified.php | |
| ################################# | |
| What you need to do is run this command : | |
| diff -u CustomerData.php CustomerDataModified.php > diff.patch | |
| ############################3 | |
| Move diff.patch in your root under a directory, example Mypatches dir . Delete the file added CustomerDataModified.php since the patch is generated with the changes. | |
| Here comes the tricky part , needs some manual modification now : When you open the diff.patch you will get something like this on the top : | |
| ########################3 | |
| --- CustomerData.php 2018-02-21 01:26:16.000000000 -0500 | |
| +++ CustomerDataModified.php 2019-01-03 03:57:47.326011737 -0500 | |
| Replace those line with this one : | |
| diff --git a/Block/CustomerData.php b/Block/CustomerData.php | |
| index 3ee2rd..8349152 111644 | |
| --- a/Block/CustomerData.php | |
| +++ b/Block/CustomerData.php | |
| ####################################### | |
| Next Step is modification of the composer.json in the root of your magento : Add the extra section (if you dont have one already) | |
| "extra": { | |
| "magento-force": "override", | |
| "patches": { | |
| "magento/module-customer": { | |
| "some description abt issue applying this patch": "Mypatches/diff.patch" | |
| } | |
| } | |
| } | |
| And there you go . Your patch is diff.patch (you can call whatever you like ) . Run composer install to apply that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment