Shelve and unshelve changes

Shelving saves the contents of a pending changelist on the P4 server without submitting them. Shelved changes can be unshelved later by you or another user into any client workspace. Use shelving to set work aside, switch tasks, share work in progress for review, or move changes between machines.

Shelving does not create a permanent file revision in the depot. Files must be open in a pending changelist before they can be shelved.

Shelve workflow

Shelve a single file

  1. In the Source Control view, right‑click the file you want to shelve.

  2. Select Shelve file.

The current contents of the file are shelved on the P4 Server. The file remains open in the changelist in your workspace.

Shelve a changelist

You can shelve all files in a pending changelist at once.

  1. In the Source Control view, right‑click the changelist.

  2. Select one of the following options:

    • Shelve changelist: Shelves all files in the changelist. What happens to your local files depends on the File Shelve Mode setting under Extensions > P4 for VS Code.

    • Shelve and revert changelist: Shelves all files and immediately reverts the local copies, leaving a clean workspace.

The files are shelved on the server.

Unshelve changes

You can restore shelved changes to your workspace.

  • To unshelve a single file, right‑click the shelved file under its changelist and select Unshelve file.

  • To unshelve all files in a changelist, right‑click the changelist and select Unshelve changelist.

The files are restored to your workspace in a pending changelist. Shelved files cannot be unshelved if the same file is already open in the target changelist.

Delete shelved changes

You can remove shelved content from the P4 Server without affecting your local files.

  • In the Source Control view, right‑click the changelist that contains shelved files.

  • Select Delete shelved files.

Only the shelved versions are removed. The pending changelist and local workspace files are not affected. Only the changelist owner can delete shelved files.

Control what happens to local files when shelving

Use the P4: File Shelve Mode setting under Extensions > P4 VS Code to control how the P4 for Visual Studio Code extension handles local workspace files during shelving:

  • prompt (default): Prompts you to choose whether to keep or remove local files.

  • swap: Removes local workspace files after shelving.

  • keep both: Keeps local workspace files after shelving.

This setting applies when shelving a file.

Hide shelved files in the Source Control view

Select the Hide Shelved Files setting under Extensions > P4 for VS Code to hide shelved file entries beneath changelists in the Source Control view.