Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Documentation | 2025.2

# p4 undo

Undo a range of revisions.

## Syntax

    p4 [g-opts] undo [-n -K] [-c change] [[FileSpec][revSpec]]

Syntax and naming conventions

## Description

The `p4 undo` command opens files to undo a set of previously submitted changes. The undone changes remain a part of the file history, but the new revisions submitted after `p4 undo` reverse their effect.

If a single revision is specified, the specified revision is undone. If a revision range is specified, the entire range is undone.

The workspace files opened by `p4 undo` are synced to the revision prior to those of the range and opened at the most recent undone revision.

Files that are opened at a revision prior to the head must be resolved prior to submission. To accomplish this, run `p4 sync` followed by `p4 resolve`.

The -n option previews the operation without changing any files.

If -c change is included, files are opened in the specified pending changelist instead of the default changelist.

See the Example below.

## Options

Option | Description
--- | ---
`-n` | Preview the operation without changing any files.
`-K` | Suppress keyword expansion when updating +k type files on the client. See File type modifiers.
`-c change` | Open files in the specified pending changelist rather than the default changelist.
`g-opts` | See Global options.

## Usage Notes

Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required
--- | --- | ---
Yes | Yes | `open`

To undo the effects of a particular change, issue this command:

    p4 undo @change

To undo all changes made on April 1, 2018, issue this command:

                p4 undo @2018/04/01,@2016/04/02

These examples open files in the default changelist. To use a numbered changelist, specify it with the `-c` option.

## Example

User Command | Result
--- | ---
The user wants the content of revision #1 to become the latest revision. p4 undo //depot2/dirE/readme.txt#2 | An undid action against that revision #2 is pending: //depot2/dirE/readme.txt#2 - opened for integrate ... undid //depot2/dirE/readme.txt#2
The user submits the file. p4 submit -d "undoing edit made in #2" | The content and history of revision #1 is now associated with the newly created revision #3 because an integrate action has completed. Submitting change 635. Locking 1 files ... integrate //depot2/dirE/readme.txt#3 Change 635 submitted.
The user decides to review the history of the file. p4 filelog //depot2/dirE/readme.txt | The p4 filelog command returns the history, indicating that revision #3 has undone revision #2. //depot2/dirE/readme.txt ... #3 change 635 integrate on 2018/10/26 by bruno@7ws (text) 'undoing edit made in #2' ... ... undid //depot2/dirE/readme.txt#2 ... #2 change 634 edit on 2018/10/26 by bruno@7ws (text) 'making #2 in depot2/dirE ' ... ... undone by //depot2/dirE/readme.txt#3 ... #1 change 234 add on 2018/05/29 by bruno@7ws (text) 'added the initial file'

## Related commands

Show integrations that have been submitted. | p4 integrated

Your search for returned results