Help:Diff

A diff is the difference between two versions of a page. It can be viewed from the page history: for every version there are potentially two radio buttons: the left column is for selecting the older version, the right column for selecting the newer one. Pressing "Compare selected versions" gives the difference between the two versions.

For special cases (the diff for a single edit or between an old and the current version) other possibilities are clicking cur or last in the page history or on the Recent Changes page. The diff is also shown during an edit conflict so you can see exactly what you need to reintegrate.

From MediaWiki 1.5 diff works also in preview, showing the difference between the currently stored version and the current version in the edit box.

How it looks
This example shows the top of the diff page (some of the links are dummies). 

The two versions are shown side-by-side. In left-to-right languages, the old version is on the left. This is reversed in right-to-left scripts. The links "Revision as of date" link to each version (from MediaWiki 1.4). If the newer version is the latest one, the link will be to the usual page and the wording will be "Current revision (date)" instead.

The (edit) link will take you to the page for editing that version. You may be warned that you are editing an out-of-date revision, and if you ignore it and continue, you will revert all the edits done after that revision.

The (undo) link on the newer revision's side will revert that specific edit. When you click the link you can check the diff page of the edit you are going to make, and the edit summary will be automatically filled in with the phrase of MediaWiki:undo-summary. This summary can be edited before you submit your edit. When you are undoing several edits at once, the auto-summary may not work. Though the link exists on all diff pages, it does not function when the revisions conflict. Often versions older than the current one can not be undone in this way. If it does not work, you will be told that the edit could not be undone and end up in the regular editing page of the current version.

Below that are links to the user page and talk page of the each user who edited the older or the newer versions. Links to the users' contribution lists are also shown. For sysops, a rollback button is also shown, allowing them to revert all of the edits done by that user. Note however that this is even shown when viewing the diff related to a version older than the latest, and when there is a newer edit done by another user, the rollback would not undo the change that is displayed.

Then the edit summaries are shown in a parenthesis. If the user has used links in their edit summary, these act as links on the diff page as well. If the editor marked the edit as an minor edit, m appears before the summary.

Previous diff and Next diff links make it possible to check earlier or later versions. When you are checking the differences between two versions in apart, you will be told that "(x intermediate revisions not shown.)".

On the old version side, paragraphs which differ from the new version are highlighted with yellow, and on the new version with green. Text removed within a paragraph is shown in red on the old version. New text within a paragraph is shown in red on the new version. If a whole paragraph was removed or added, the text is not red but just black, while the other side is blank (white). Unchanged text is black on grey, only parts before and after changed text is shown.

After the table of differences, the latest of the two compared versions is shown fully, unless one specifies in the preferences that this is not done.

Simple way to make a diff link
Find the page which contains the edit you want to refer to. Click on its history tab. Find the edit in the history list. (If that's a problem, clicking on the word "last" in the list will let you read the edit.) Right-click on its "last" button and select "Copy link location" (or however your browser expresses it). The diff you want is now in your clipboard. (Or, click on "last" and you are viewing the diff. Copy the url of the page you are then viewing.) Paste it into your text where you want it to appear. Include the whole of it, http:// and all. Put single square brackets "[]" around it.

URL
Any two versions, even of two different pages, can be compared using URLs.

Open the revision of one page that you wish to compare to another, for example, and the revision of the other page that you wish to compare, for example. Copy the oldid number of one page ( in the first example) and replace the text   with  :. Paste this string into the URL of the other page between that page's title and its oldid ( in the second example), so you have something like this:



You may remove the page title ( in the example above) from the URL if you wish, but this is not necessary. The resulting diff will compare the given versions of the two pages.

To compare the current version of the page and a given oldid, you can put "current" after "diff=" instead of an oldid. For example, would compare the current version of this page with the version that has oldid 124558.

Deleted revisions
A sysop can see deleted revisions, but not directly apply a diff. For this purpose the page has to be (temporarily) restored (at least the two revisions between which the diff is desired).

Redirect
A diff is also used to render a redirect page as an ordinary page, showing also content after the redirect itself. The alternative is using preview.

Miscellaneous
When moving or copying a piece of text within a page or from another page, and also making other edits, it is useful to separate these edits. This way the diff function can be usefully applied for checking these other edits.

The diff shows differences per line. Some editors find that adding manual line breaks improves the diff function.

If searching the edit summaries does not help, to search for the edit between two revisions in which a particular change from some text A to text B was made (to find the user, the edit summary, and the context is which the change was made), take the diff between 1/3 and 2/3 of the "search space". From the diff and/or the "2/3" version one can conclude in which of the three parts the change was made (if there is A at 2/3, the change was made later; if there is B at 1/3 the change was made before; if the diff shows the change it was made between 1/3 and 2/3). This process can be repeated, every time reducing the search space by a factor 3. For changes in the wikitext which do not affect the rendered page, such as substitution of a template or editing HTML comments, take the diff between 1/2 and the end of the "search space" (if the diff shows the change it was made between 1/2 and the end, otherwise between the start and 1/2). If the change from A to B was made in steps (one finds a time interval where part of the change was made) one can continue the search for that part or the other part, or do the rest of the search for each of the two parts of the change.

One can either search for a deleted phrase or for an added phrase. It is easiest to use a search phrase that applies both for wikitext and for rendered text. For example, to search for the addition of the piped link p|q, search for q.

Copying the search phrase to your clipboard is on most browsers accomplished by highlighting the text and choosing "copy" from edit menu options, or clicking control+c. Searching is done by opening your browser's find option ("find" or control+f), pasting the text saved to your clipboard ("paste" or control+v), and searching for it.

In the case of the Classic skin with quickbar, the diff page does not have the quickbar, to provide more space. Therefore the diff page is also useful for viewing the page on full screen width, without changing the preferences. With the Monobook skin the panels on the left are also on the diff page.

On a diff page sometimes the display may be wider than the screen, because there are two columns, but also because URLs (especially long ones) are not hidden. In such cases, you must then use the horizontal scrollbar of the browser to see all the display.