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

P4 CLI Documentation | 2026.1

# p4 unshelve

Retrieve shelved files and the stream spec from a pending change into a workspace.

## Syntax

    p4 [g-opts] unshelve -s shelvedchange [options] [-As]
    p4 [g-opts] unshelve -s shelvedchange [options] [-Af [FileSpec]]
        where [options] refers to
        [-f -n] [-c change] [-b branch | -S stream [-P parent]]

Syntax and naming conventions

## Description

Use the `p4 unshelve` command to retrieve shelved files from the specified pending changelist, open them in a pending changelist, and copy them into your workspace.

Unshelving copies the shelved files into the user’s workspace as they existed when they were shelved. For example, a file open for edit when shelved is also open for edit in the unshelving user’s workspace.

Unshelving files from a pending changelist is restricted by the user's permissions on the files. Similarly, access to the shelved files from a pending changelist is controlled by the user’s permissions on the files.

In addition to the files being unshelved, `p4 unshelve` also unshelves any open stream specification. To learn more, see `p4 stream`.

You can limit the files to be unshelved by specifying a FileSpec.

A shelf that was promoted from an edge server to the commit server can have its files unshelved on a different P4 Server from the one where the shelf originated. Promotion can be done manually or automatically. To learn more, see Promoting shelved changelists in the P4 Server Administration Documentation.

By default, the unshelve command acts on both the files and the stream spec.

- To unshelve only files, use p4 unshelve -Af
- To unshelve only the stream spec, use p4 unshelve -As

See also the p4 help streamcmds command-line output.

### Unshelve over an opened file

Unshelving a file over a file that is already opened is permitted if both shelved file and opened file are opened for `edit`. In a multi-server environment, the shelf must either be promoted to the commit server or have been created on the same edge server.

After unshelving, the workspace file is flagged as unresolved, and p4 resolve must be run to resolve the differences between the shelved file and the workspace file.

Unshelving a file opened for `add` when the file already exists in the depot results in the file being opened for edit. After unshelving, the workspace file is flagged as unresolved, and p4 resolve must be run to resolve the differences between the shelved file and the depot file at the head revision.

### Overwrite with -f option

The `-f` option can force unshelve to succeed if it fails because a file not open for add or edit is somehow writable. However, it is prudent to examine the file in question before using `-f` because the content of that file would be overwritten and permanently lost.

### Delete a shelf

To delete a shelf, see the `-d` option of the p4 shelve command.

### Recover an obliterated file if it remains in a shelf

Suppose the `//depot/project1/test.c` file was obliterated with p4 obliterate but happens to be in shelved changelist `123`. You cannot unshelve the file, but you can recover its contents with the p4 print command:

`p4 print -o recovered-test.c //depot/project1/test.c@=123`

where `recovered-test.c` gets the contents of the `test.c` file.

### Access shelved content for files that are exclusively locked

P4 Server does not support unshelving open files into a read-only pending changelist. If a shelved file is exclusively locked, the lock prevents `p4 unshelve` from succeeding for any other user.

To access the shelved content without running `p4 unshelve`, use the p4 print command with the `-o` option and the `@=shelved-change` version selector. For a worked example, see Unshelve changelists.

### Unshelve a shelf owned by another stream

To unshelve a shelf owned by another stream, a branch mapping is necessary so that the target stream has a "view" of the source file. The view requires a mapping between a source stream (the parent) and the target stream (the child), such as:

    //parent_path/... //child_path/...

Such a mapping is typical of the mainline model:

    //stream/main... //stream/dev1/...

where //stream/main is the mainline parent of the //stream/dev1 development stream.

A resolve might be required before you can submit.

#### Unshelve from a child stream

It is possible to shelve files in a stream and then unshelve into its parent. For example, you might have a bug fix in a development child stream and now want to unshelve the files into the mainline parent stream.

The -S stream option specifies a stream-derived branch mapping between the specified stream and its parent, through which the shelved files are mapped to enable unshelving.

When working in the target mainline parent stream:

    p4 unshelve -s 6 -S  //stream/dev1

where //stream/dev1 is the name of a child stream.

#### Unshelve from a stream that is not the parent stream

You can unshelve from a stream that is not a child of the stream you are working in. To do so, include the -P parent option as a suboption of the -S stream option. In this example, //stream/dev1/ and //stream/dev2/ are either unrelated streams or sibling streams that share a common ancestor.

When working in the target stream, //stream/dev1:

    p4 unshelve -s 8 -S //stream/dev1 -P //stream/dev2

where //stream/dev2 is treated as if it were the parent of the //stream/dev1 stream for branch mapping.

Similarly, if //stream/main is the parent of //stream/dev1, you can unshelve from the parent into the child:

    p4 unshelve -s 6 -S  //stream/main -P //stream/dev1

See also Unshelve to a sparse stream.

## Options

Option | Description
--- | ---
-As | Unshelve only the stream spec.
-Af | Unshelve only files. If a FileSpec ... is included, only matching files are unshelved. Otherwise all the files are unshelved.
`-b branch` | Specifies a branch spec through which the shelved files are mapped before unshelving. This option enables you to shelve files in one branch and unshelve them in another. For example, you might have fixed a bug in a development branch (or stream) and now want to unshelve the files into the different branch (or stream). See the example, p4 unshelve -s 65 -b dev1-to-dev2. In a distributed environment, an additional requirement is that the shelve was created on the same edge server.
`-c change` | Specify a changelist number in the user’s workspace into which the files are to be unshelved. By default, `p4 unshelve` retrieves files into the default changelist.
`-f` | Force the overwriting of writable (but unopened) files during the unshelve operation. You might have changed files in your workspace without checking them out. If you are unshelving work done by another user, this guarantees that your workspace gets a copy of that user's work.
`-n` | Preview the results of the unshelve operation without actually restoring the files to your workspace.
`-S stream` | Specifies a stream-derived branch mapping between the specified stream and its parent, through which the shelved files are mapped before unshelving. This option enables you to shelve files in a stream and unshelve in its parent or child stream. For example, you might have a bug fix in a development stream and now want to unshelve the files into the parent stream. For sparse streams, a message might indicate that a merge down from the parent stream is required before unshelving from the parent stream to the sparse stream. See also the `-P` option.
`-P parent` | The -P flag can be used to generate the view as if the -P stream was the parent of the -S stream. Overrides the parent defined in the source stream specification. See also the `-S` option.
`-s shelvedchange` | Specify the pending changelist number that contains the shelved files to unshelve.
`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`

## Examples

Suppose you have shelved a pending changelist number `65` with both stream spec and files.

p4 unshelve -s 65 Unshelve the entire shelve at the specified changelist number.
p4 unshelve -s 65 -As Unshelve only the stream spec.
p4 unshelve -s 65 -Af a1/... Unshelve only the files that match the FileSpec.
    p4 unshelve -s 65 -b dev1-to-dev2
Use the -b option to specify a branch spec, which causes files to be unshelved to a different branch than the original branch.

## Related commands

To store files from a pending changelist into the depot without submitting them. | `p4 shelve`

Your search for returned results