p4 unshelve
Restore 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]]
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 will also be 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 has been promoted from an Edge Server to the Commit Server can have its files unshelved on a different Helix Core Server from the one where the shelf originated. Promotion can be done manually or automatically. To learn more, see Promoting shelved changelists in the Helix Core Server Administrator Guide.
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.
Recovering an obliterated file if it remains in a shelf
Suppose the //depot/project1/test.c
file has been 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.
Options
-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. |
|
Specifies a branch spec through which the shelved files will be mapped prior to 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 mainline branch (or stream). In a distributed environment, an additional requirement is that the shelve was created on the same edge server. |
|
Specify a changelist number in the user’s workspace into which
the files are to be unshelved. By default, |
|
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 will get a copy of that user's work. |
|
Preview the results of the unshelve operation without actually restoring the files to your workspace. |
|
Unshelve to the specified parent stream. Overrides the parent defined in the source stream specification. |
|
Specify the pending changelist number that contains the shelved files to unshelve. |
|
Specifies a stream-derived branch mapping between the specified stream and its parent, through which the shelved files will be mapped prior to 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. See also the |
|
See Global options. |
Usage Notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
Yes |
Yes |
|
Examples
Suppose we 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. |
Related commands
To store files from a pending changelist into the depot without submitting them. |