Revert files to a previous revision.


bzr revert [FILE...]

-v, --verbose

Display more information.

-h, --help

Show help message.

-q, --quiet

Only display errors and warnings.


Remove pending merge marker, without changing any files.


Show usage message and options.


Do not save backups of reverted files.

-r ARG, --revision=ARG

See “help revisionspec” for details.


Giving a list of files will revert only those files. Otherwise, all files will be reverted. If the revision is not specified with ‘–revision’, the last committed revision is used.

To remove only some changes, without reverting to a prior version, use merge instead. For example, “merge . –revision -2..-3” will remove the changes introduced by -2, without affecting the changes introduced by -1. Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.

By default, any files that have been manually changed will be backed up first. (Files changed only by merge are not backed up.) Backup files have ‘.~#~’ appended to their name, where # is a number.

When you provide files, you can use their current pathname or the pathname from the target revision. So you can use revert to “undelete” a file by name. If you name a directory, all the contents of that directory will be reverted.

If you have newly added files since the target revision, they will be removed. If the files to be removed have been changed, backups will be created as above. Directories containing unknown files will not be deleted.

The working tree contains a list of revisions that have been merged but not yet committed. These revisions will be included as additional parents of the next commit. Normally, using revert clears that list as well as reverting the files. If any files are specified, revert leaves the list of uncommitted merges alone and reverts only the files. Use bzr revert . in the tree root to revert all files but keep the recorded merges, and bzr revert --forget-merges to clear the pending merge list without reverting any files.

Using “bzr revert –forget-merges”, it is possible to apply all of the changes from a branch in a single revision. To do this, perform the merge as desired. Then doing revert with the “–forget-merges” option will keep the content of the tree as it was, but it will clear the list of pending merges. The next commit will then contain all of the changes that are present in the other branch, but without any other parent revisions. Because this technique forgets where these changes originated, it may cause additional conflicts on later merges involving the same source and target branches.

See also:

cat, export

Previous topic


Next topic


This Page