:navigation-title: Create patch .. include:: /Includes.rst.txt .. index:: single: Patch .. _quickstart-patch: Quick Start: Create a patch =========================== Please read :ref:`quickstart-intent` for a longer text about an example which kind of patch you could contribute. Now with this example in mind, we have two modified files that we want to commit: * :file:`typo3/sysext/backend/Classes/Form/Element/JsonElement.php` * :file:`typo3/sysext/backend/Tests/Unit/Form/Element/JsonElementTest.php` .. note:: Ensure that your current working directory is the one used in previous steps, here :bash:`cd $HOME/work/TYPO3-Contribute`. .. rst-class:: bignums-xxl 1. Create a matching Forge Ticket Every patch needs to have a reason to be introduced. For this, you need to `create an issue on Forge `__, see :ref:`forge-introduction`. With our example you could create an issue like: **Tracker**: Task **Subject**: The TCA Json FormEngine input needs a HTML5 attribute "input-type='json'" **Description**: (Describe why the attribute would be needed. Conclude with "I will create a patch for this" to let other know you'll be working on it) Now note down the number of your issue which you can see next to the title after creation, or in the URL (for example: `12345`). 2. Ensure proper Git state Make sure you are in the right directory and following the previous steps, you should not have any other modified files: .. code:: bash :caption: **Check git status of the repository** git status The output should be: .. code:: text On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: typo3/sysext/backend/Classes/Form/Element/JsonElement.php modified: typo3/sysext/backend/Tests/Unit/Form/Element/JsonElementTest.php no changes added to commit (use "git add" and/or "git commit -a") 3. Add changed files to git stage: .. code:: bash :caption: **Add single files to git stage to be pre-selected for a commit** git add typo3/sysext/backend/Classes/Form/Element/JsonElement.php && \ git add typo3/sysext/backend/Tests/Unit/Form/Element/JsonElementTest.php .. note:: Please ensure to only add files related to your change to the stage, and discard unrelated files if reasonable. If your change is a breaking, a feature or deprecation, add a :ref:`Changelog entry `. 4. Commit the files .. code:: bash :caption: **Create a git commit for files in the git stash** git commit Now your default terminal editor should open (usually `vi` or `nano`) and show this: .. code:: text :caption: **The commit message template is loaded to help with commit message structure** [BUGFIX|TASK|FEATURE|DOCS] Resolves: # Releases: main # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Your branch is up to date with 'origin/main'. # # Changes to be committed: # modified: typo3/sysext/backend/Classes/Form/Element/JsonElement.php # modified: typo3/sysext/backend/Tests/Unit/Form/Element/JsonElementTest.php # .. code:: text :caption: **Replace that to read:** [TASK] Add HTML5 spec "input-type='json'" to TCA type=json Resolves: #12345 Releases: main Close your editor with saving the commit message. For proper formatting and wording of a commit message, please read the details in :ref:`commitmessage`. 5. Push to Git repository .. code:: bash :caption: **Push the commit to configured remote push url (Gerrit)** git push .. code:: text :caption: **Output:** Enumerating objects: 11859, done. Counting objects: 100% (11859/11859), done. Delta compression using up to 10 threads Compressing objects: 100% (3900/3900), done. Writing objects: 100% (9919/9919), 3.06 MiB | 9.53 MiB/s, done. Total 9919 (delta 6847), reused 8104 (delta 5373), pack-reused 0 (from 0) remote: Resolving deltas: 100% (6847/6847) remote: Processing changes: refs: 1, new: 1, done remote: remote: SUCCESS remote: remote: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85025 [TASK] Add HTML5 spec "input-type='json'" to TCA type=json [NEW] remote: To ssh://review.typo3.org:29418/Packages/TYPO3.CMS.git * [new reference] main -> refs/for/main 6. Open review URL Open the given URL `https://review.typo3.org/c/Packages/TYPO3.CMS/+/85025` in your browser. You should now see your contributed patch! Also, automatically the Pipeline will now run server-side tests on your patch. Coding Guidelines will be addressed. This may lead to further patch modification. 7. Announce your patch, gather feedback, improve Sometimes, feedback will come naturally to your patch, by people seeing it in the Gerrit patch pipeline. You are welcome to join the Slack channel `#typo3-cms-coredev` and :ref:`advertise your contribution for feedback `. You might want to check :ref:`common-review-checks` for things that people will review in your patch, hopefully leading to be merged. Depending on the feedback you may need to further refine your patch. You can do this by locally editing your files. Then it is **vital** that you do not perform a new git commit, but always only **amend your commit**: .. code:: bash # ... edit files # ... commit all changed files git commit -a --amend git push See :ref:`lifeOfAPatch-improve-patch` for details. 8. Cleaning up It's important to cleanup your local checkout after working on a change or reviewing it, to avoid stacking multiple changes into a **not intentional** relation chain. See :ref:`resetting ` for information on this. 9. Special notes In some cases you may need to alter assets of the TYPO3 Core, like `TypeScript` or `SCSS`. See :ref:`building-assets` for how to build and then commit these files to your patch. 10. Thank you! The TYPO3 community is thankful for you following this guide, and we hope once you have set up your development environment for it you can enjoy being an active contributor!