Alert: Contributors to WordPress may submit patches created via either Git andSVN. This documentation focuses on the Git option.
Git is a distributed version control system originally created by Linus Torvalds to assist with the management of the Linux kernel.
The canonical WordPress repository is managed using Subversion. To better support developers who are more comfortable working with Git, an official, up-to-date Git mirror of the WordPress repository is available at git://develop.git.wordpress.org.
The WordPress Git mirror contains a complete history of the codebase. Each Subversion commit is represented by a Git changeset. Use the git log utility to browse the history of the project. The layout of the repository is as follows:
The master branch, which corresponds to SVN trunk. This is the bleeding-edge branch, containing the alpha version of the next major release. Except in special cases, contributors should prepare their patches against the master branch.
A branch exists corresponding to each major release series, named using the first two digits of versions in that series. For example, 4.5.1 was released from the 4.5 branch. Use git branch -r to view a complete list of branches in the remote repository, and use commands like git checkout -b 4.5.x origin/4.5 to create local branches that track remote branches.
All WP releases (starting with 1.5.0) are represented by Git tags. Use git tag to browse the list.
Suggested improvements and bugfixes for WordPress should be submitted as patches. A patch is 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 (after the Unix command to generate a differences file). Patches have the extension of either .patch or .diff. Patch files can then be submitted for consideration to WordPress Trac, the project’s official bugtracker.
Using the git cli client, you can create a patch file as follows:
Clone the repository to your local machine: $ git clone git://develop.git.wordpress.org/ /path/to/wordpress
Create a working branch. To keep your local checkout organize, it’s suggested that you use the Trac ticket number as part of your branch name, eg: $ git checkout -b 30000-add-more-alots
Make your modifications to the codebase. Stage the changes (git add), and commit (git commit). The official git documentation includes a tutorial on this.
Return to the master branch with $ git checkout master and use git diff to review the differences between your local branch and the master branch: $ git diff 30000-add-more-alots
Once you’re ready to submit your patch to Trac, generate a patch file using git diff, specifying that the output should be saved in a .patch file. In general, the file name should be the ticket number you are working on with .patch as the extension. $ git diff 30000-add-more-alots > 30000.patch