{"id":3929,"date":"2012-07-12T21:17:06","date_gmt":"2012-07-12T21:17:06","guid":{"rendered":"http:\/\/make.wordpress.org\/core\/handbook\/?page_id=3929"},"modified":"2025-07-01T14:54:37","modified_gmt":"2025-07-01T14:54:37","slug":"submitting-a-patch","status":"publish","type":"handbook","link":"https:\/\/make.wordpress.org\/core\/handbook\/tutorials\/trac\/submitting-a-patch\/","title":{"rendered":"Submitting a Patch"},"content":{"rendered":"<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once you\u2019ve edited the file and tested it, you need to create a <span tabindex='0' class='glossary-item-container'>patch<span class='glossary-item-hidden-content'><span class='glossary-item-header'>patch<\/span> <span class='glossary-item-description'>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 <strong>diff<\/strong>. A patch can be <em>applied<\/em> to a codebase for testing.<\/span><\/span><\/span> and upload it to the corresponding <span tabindex='0' class='glossary-item-container'>Trac<span class='glossary-item-hidden-content'><span class='glossary-item-header'>Trac<\/span> <span class='glossary-item-description'>An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress.<\/span><\/span><\/span> <span tabindex='0' class='glossary-item-container'>ticket<span class='glossary-item-hidden-content'><span class='glossary-item-header'>ticket<\/span> <span class='glossary-item-description'>Created for both bug reports and feature development on the bug tracker.<\/span><\/span><\/span> so other people can see and test the changes. You can create a <em>patch<\/em> a number of ways.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When using an <span tabindex='0' class='glossary-item-container'>IDE<span class='glossary-item-hidden-content'><span class='glossary-item-header'>IDE<\/span> <span class='glossary-item-description'>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.<\/span><\/span><\/span> 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 <code>\/src<\/code> directory, the <code>wp-config-sample.php<\/code> file, etc.).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Windows<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If you are on Windows,<\/strong> consider using <a href=\"http:\/\/tortoisesvn.net\/\">Tortoise SVN<\/a>. You can <a href=\"https:\/\/make.wordpress.org\/core\/handbook\/tutorials\/working-with-patches\/#creating-a-patch-with-tortoisesvn\">read our tutorial on creating a patch with Tortoise SVN<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mac\/Linux Command Line<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">From <a href=\"http:\/\/markjaquith.wordpress.com\/2005\/11\/02\/my-wordpress-toolbox\/\">Mark Jaquith\u2019s Tutorial<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make a patch, for filename.php:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$ svn diff filename.php &gt; filename.diff<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make a patch for all files modified in the checkout:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$ svn diff &gt; big_patch.diff<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apply a patch from someone else:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$ patch -p0 &lt; patch.diff<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are some GUI options for the Mac, as well \u2014 you just need it to create patch files (Versions cannot, for example).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also: <a href=\"http:\/\/scribu.net\/wordpress\/svn-patches-from-git.html\">creating SVN patches using Git<\/a>, from Cristi Burca.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Submitting a patch via <span tabindex='0' class='glossary-item-container'>GitHub<span class='glossary-item-hidden-content'><span class='glossary-item-header'>GitHub<\/span> <span class='glossary-item-description'>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 \u2018pull request\u2019 where code changes done in branches by contributors can be reviewed and discussed before being merged by the repository owner. <a href=\"https:\/\/github.com\/\">https:\/\/github.com\/<\/a><\/span><\/span><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer using GitHub for code reviews and collaboration, the WordPress <span tabindex='0' class='glossary-item-container'>core<span class='glossary-item-hidden-content'><span class='glossary-item-header'>Core<\/span> <span class='glossary-item-description'>Core is the set of software required to run WordPress. The Core Development Team builds WordPress.<\/span><\/span><\/span> code is available as a <a href=\"https:\/\/github.com\/wordpress\/wordpress-develop\">GitHub mirror<\/a> where you can submit patches.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Fork the GitHub mirror to your own account using the <strong>Fork<\/strong> option at the top of the GitHub page.<\/li>\n\n\n\n<li>Clone your fork to your local computer. Replace <code>your-username<\/code> with your GitHub username.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git clone git@github.com:your-username\/wordpress-develop.git<\/code><\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Create a new <span tabindex='0' class='glossary-item-container'>branch<span class='glossary-item-hidden-content'><span class='glossary-item-header'>branch<\/span> <span class='glossary-item-description'>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\".<\/span><\/span><\/span> to work on a specific Trac ticket \u2014 never work directly on <span tabindex='0' class='glossary-item-container'>trunk<span class='glossary-item-hidden-content'><span class='glossary-item-header'>trunk<\/span> <span class='glossary-item-description'>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.<\/span><\/span><\/span>. Name it after the Trac ticket number and a brief description of the change.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git checkout -b 44722-fix-issue-in-component<\/code><\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Make your code changes, commit them, and push your branch to your fork.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git push origin 44722-fix-issue-in-component<\/code><\/p>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Go to your fork on GitHub. If your GitHub account is linked to your <span tabindex='0' class='glossary-item-container'>WordPress.org<span class='glossary-item-hidden-content'><span class='glossary-item-header'>WordPress.org<\/span> <span class='glossary-item-description'>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.  <a href=\"https:\/\/wordpress.org\/\">https:\/\/wordpress.org\/<\/a><\/span><\/span><\/span> profile, GitHub will prompt you to open a Pull Request. Make sure the title includes the Trac ticket number (e.g., <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/44722\">#44722<\/a>: Fix X issue in Y component).<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">While first forking the mirror and then cloning it locally is recommended, if you\u2019ve already cloned the <code>wordpress\/wordpress-develop<\/code> mirror, you can add your fork as a remote repository using git remote add.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git remote add fork git@github.com:your-username\/wordpress-develop.git<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll then still be able to create a local branch, but will need to push to the correct remote.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about working with remote repositories, see the <a href=\"https:\/\/docs.github.com\/en\/get-started\/git-basics\/managing-remote-repositories\">GitHub documentation<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more details on GitHub integration, see the <a href=\"https:\/\/make.wordpress.org\/core\/handbook\/contribute\/git\/github-pull-requests-for-code-review\/\">GitHub Pull Requests for Code Review documentation<\/a>.<\/p>\n<nav class='o2-post-footer-actions'><ul class='o2-post-footer-action-row'><\/ul><div class='o2-post-footer-action-likes'><\/div><ul class='o2-post-footer-action-row'><\/ul><\/nav>","protected":false},"author":5286302,"featured_media":0,"parent":4911,"menu_order":10,"template":"","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"footnotes":""},"class_list":["post-3929","handbook","type-handbook","status-publish","hentry","author-nacin","make-submitting-a-patch"],"revision_note":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/handbook\/3929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/handbook"}],"about":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/types\/handbook"}],"author":[{"embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/users\/5286302"}],"version-history":[{"count":28,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/handbook\/3929\/revisions"}],"predecessor-version":[{"id":118584,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/handbook\/3929\/revisions\/118584"}],"up":[{"embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/handbook\/4911"}],"wp:attachment":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/media?parent=3929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}