Overview
Once you’ve edited the file and tested it, you need to create a patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. and upload it to the corresponding TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. ticketticket Created for both bug reports and feature development on the bug tracker. so other people can see and test the changes. You can create a patch a number of ways.
When using an IDEIDE Integrated Development Environment. A software package that provides a full suite of functionality to software developers/programmers. Normally an IDE includes a source code editor, code-build tools and debugging functionality. or a Subversion client a patch can be created directly by the application. The patch should be created from the root directory (the folder that contains the /src
directory, the wp-config-sample.php
file, etc.).
Windows
If you are on Windows, consider using Tortoise SVN. You can read our tutorial on creating a patch with Tortoise SVN.
Mac/Linux Command Line
Make a patch, for filename.php:
$ svn diff filename.php > filename.diff
Make a patch for all files modified in the checkout:
$ svn diff > big_patch.diff
Apply a patch from someone else:
$ patch -p0 < patch.diff
There are some GUI options for the Mac, as well — you just need it to create patch files (Versions cannot, for example).
Also: creating SVN patches using Git, from Cristi Burca.
Submitting a patch via GitHub
If you prefer using GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ for code reviews and collaboration, the WordPress coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. code is available as a GitHub mirror where you can submit patches.
- Fork the GitHub mirror to your own account using the Fork option at the top of the GitHub page.
- Clone your fork to your local computer. Replace
your-username
with your GitHub username.
git clone git@github.com:your-username/wordpress-develop.git
- Create a new branchbranch A directory in Subversion. WordPress uses branches to store the latest development code for each major release (3.9, 4.0, etc.). Branches are then updated with code for any minor releases of that branch. Sometimes, a major version of WordPress and its minor versions are collectively referred to as a “branch”, such as “the 4.0 branch”. to work on a specific Trac ticket — never work directly on trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running “trunk”, then you are on the latest revision.. Name it after the Trac ticket number and a brief description of the change.
git checkout -b 44722-fix-issue-in-component
- Make your code changes, commit them, and push your branch to your fork.
git push origin 44722-fix-issue-in-component
- Go to your fork on GitHub. If your GitHub account is linked to your WordPress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/ profile, GitHub will prompt you to open a Pull Request. Make sure the title includes the Trac ticket number (e.g., #44722: Fix X issue in Y component).
While first forking the mirror and then cloning it locally is recommended, if you’ve already cloned the wordpress/wordpress-develop
mirror, you can add your fork as a remote repository using git remote add.
git remote add fork git@github.com:your-username/wordpress-develop.git
You’ll then still be able to create a local branch, but will need to push to the correct remote.
To learn more about working with remote repositories, see the GitHub documentation.
For more details on GitHub integration, see the GitHub Pull Requests for Code Review documentation.
10 responses to “Submitting a Patch”
This is probably worth reading through in order to flesh this list out.
https://codex.wordpress.org/User:HEngel/How_To_Become_A_WordPress_Developer
There are 3 links to Mozilla/Firefox that should be replaced by WordPress-equivalent.
Replace: Picking bugs to work on: https://developer.mozilla.org/en/Hacking_Firefox
With: Picking bugs to work on: https://core.trac.wordpress.org/report
Replace: Knowing where to ask for help: https://developer.mozilla.org/en/Hacking_Firefox
with: Knowing where to ask for help: (forum? IRCIRC Internet Relay Chat, a network where users can have conversations online. IRC channels are used widely by open source projects, and by WordPress. The primary WordPress channels are #wordpress and #wordpress-dev, on irc.freenode.net.?)
I found those Mozilla pages in my research and I want them to inspire us as a good model. To put it another way, I don’t think our current equivalents are good enough.
I wrote a guide to contributing to WP using GithubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ for Mac: https://docs.google.com/a/wordsforwp.com/document/d/16Hzc0_Z1c8VSMJplAk4dcBter3ntlfVeyyCO56VANA4/edit
Would like to contribute it to the manual but not sure how. cc @ipstenu @andrewspittle
Do we have a page (or section) anywhere yet which mentions that trivial patches that *only* fix coding standards are discouraged?
https://make.wordpress.org/core/2011/03/23/code-refactoring/
Couple of things:
Agree on the first point, came here to make that comment 😉
I am trying to submit my first patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing., but the instructions for Windows are not very clear. It says to use tortoisesvn, but it doesn’t give any instructions how. Thanks!
Evan, I just wrote an article yesterday that walks you through creating and submitting a patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. using TortioseSVN: https://www.doitwithwp.com/submit-patch-wordpress-core-beginners/