Skip to content

mw dev mediawiki update-code

Releasev0.35.0 · cfeceb67

mw dev mediawiki update-code [flags]

Update core and checked-out skins/extensions. Preview any mode without contacting remotes or changing source checkouts:

Terminal window
mw dev mediawiki update-code --dry-run
mw dev mediawiki update-code
mw dev mediawiki update-code --mode=stash
mw dev mediawiki update-code --mode=mop

Git-only updates and dry runs do not require Docker to be installed or running. The code directory is read from MEDIAWIKI_VOLUMES_CODE in the selected development context. Configure it first with mw dev mediawiki get-code.

The default, --mode=ff-only, fast-forwards clean checkouts on their existing tracking branches. Dirty worktrees (including untracked files), detached HEADs and branches without an upstream are skipped and listed. Diverged branches or failed fetches return an error while independent repositories are still checked.

--mode=stash saves tracked and untracked changes, fast-forwards the current branch, and reapplies the changes with their staged/unstaged state preserved. It checks the saved changes in a temporary worktree before advancing the original checkout. If the update or reapplication fails, it attempts to restore the original branch, commit, index and worktree. Successful restoration is reported as restored with a nonzero exit status; failed restoration is reported as recovery-needed. Detached HEADs and branches without an upstream are still skipped. Local commits are not rebased; a diverged branch is left unchanged and reported as an error.

--mode=mop saves tracked and untracked changes and leaves them saved. It fetches origin, switches to its advertised default branch (usually main or master), and resets that local branch to the remote tip. It can also start from a detached HEAD. The previous HEAD and any existing local default-branch tip are preserved under recovery refs before reset, so local commits remain reachable. A default branch checked out in another worktree is not forcibly taken over. Dry-run uses local remote refs to infer the default branch; the real update asks origin.

Both stash modes retain the saved stash even after a successful update or restoration. Output identifies stable recovery refs under refs/mwcli/update-code/, including /original, /default when applicable, and /stash when there were changes. For example, use git stash apply --index with the printed stash ref to restore saved changes, or create a recovery branch from the printed original commit ref. Existing stash entries are not popped or dropped. Ignored files are not stashed; an update that would overwrite them is refused. Finish any merge, rebase or cherry-pick before using these modes.

Core is processed first. Submodules are handled individually, without recursive Git checkout behavior. A superproject stash cannot save dirty nested worktrees; if it remains dirty after stashing, it is restored and reported instead of reset. Each repository is independent: successful updates are retained if another fails. If automatic restoration itself fails, the batch stops and reports recovery-needed alongside the recovery refs; it does not claim the original state was restored.

--composer runs Composer update in the MediaWiki PHP container only after every source checkout succeeds, with none skipped. Docker is required for this step; --dry-run --composer only previews it. Source updates are not rolled back if Composer fails. Without this flag, Composer is not run.

This command does not run database maintenance. After reviewing source/dependency changes, use maintenance explicitly, for example:

Terminal window
mw dev mediawiki foreachwiki update.php -- --quick

For a workflow combining source updates, dependency updates, database maintenance and Git recovery, see mw help guides dev update-code.

--composer
Run Composer update in the PHP container after all source checkouts succeed
--dry-run
Show eligible/skipped repositories without fetching or updating
--mode <string>
Update mode: ff-only, stash (reapply changes), or mop (save changes and reset to the default branch) Default: ff-only.
-u, --user <string>
User for the optional Composer command Default: 1000:1000.
-c, --context <string>
Development context to use (overrides CONTEXT) Default: default.
--help
Help for this command
--no-interaction
Do not ask any interactive questions
-v, --verbose <count>
Increase output verbosity. Example: --verbose=2 or -vv
Terminal window
mw dev mediawiki update-code --dry-run
mw dev mediawiki update-code
mw dev mediawiki update-code --mode=stash
mw dev mediawiki update-code --mode=mop --dry-run
mw dev mediawiki update-code --mode=mop
mw dev mediawiki update-code --composer
Report an issue with this page

Report a documentation issue

The report includes this page’s link, section and documentation version.

Review and submit on Phabricator, or run the command using your saved CLI profile. The command asks before creating the task.