Is there an equivalent to git stash in perforce? Is there an equivalent to git stash in perforce? git git

Is there an equivalent to git stash in perforce?


Perforce 2009.2 has shelve and unshelve, that let you put modifications on the server, without checking them in.http://blog.perforce.com/blog/?p=1872

I think that provides the sort of functionality you want?

If you aren't yet using 2009.2, there are also P4_Shelve and p4tar as possible alternatives.


Regarding branching, I doubt you can "branch" locally in Perforce, nor could you natively stash.

  • Git is based on a graph of commits (a DAG - Directed Acyclic Graph actually), which will display only the content of a commit (trees and blobs)
  • Perforce is a linear VCS, based on composition of selection rules (it will compose what to display based on local selection rules)

Regarding branching:

  • A branch in Git is just a light-weight and local alias to a head[*] / tip commit.
  • A branch in Perforce is:
    • a codeline (most likely meaning when used as a noun)
    • a branch view specification (as in the entity created by "p4 branch" command - also a noun) - these are talked about below
    • when used as a verb ("to branch") it means to use the "p4 integrate" command to create a new codeline (or branch!) of one or more files

As mentioned in this introduction to perforce branching, Perforce, being heavily linked to its central depo, need to create the relevant metadata for each files to create a branch.
Git would only write some bits to register the creation of a new branch!

[*] git branches are stored in the .git/refs/heads/ subdirectory


A future version of Perforce will have private local branching. P4Sandbox will allow you to have a local, disconnected subset of the depot. You can pull from the central server, do whatever you want in your sandbox (including branching and integrating) and then, if you wish, push back to the central server.

Shelving is the closest equivalent of git stash, as explained in Douglas Leeder's answer.

(Although it initially appeared that P4Sandbox would make its debut in version 2011.1, the 2011.1 beta does not have the feature, nor can I find any mention of it in the documentation for that version. As of August 2011, the P4Sandbox beta was slated for "this fall".)