Streams and Branching
Streams are Perforce’s term for branches. They are variant versions of a body of code. You can read more about them in the "Codelines, Branching and Streams" chapter of the P4 User’s Guide.
When using a personal server created by p4 init
or p4 clone
, Perforce
uses streams as containers for your code. Perforce will create a stream
named 'main' to contain the content created or cloned. If, in working with
your personal server, you need to create new streams—also known as
branching—you can do so with the p4 switch
command. You can then use
merge and copy as normal to move individual changes between streams.
Note
Although you can switch between streams on a shared server, you
cannot use p4 switch
to create new streams on shared servers.
List streams
To display the current stream, issue p4 switch
with no options.
$ p4 switch
main
main is the default stream created by the p4 clone
command.
Pass the -l
option to p4 switch to list all known streams.
$ p4 switch -l
main *
The asterisk indicates the current stream. As we haven’t yet created any other streams, main is the only one listed and is the current stream.