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

P4 CLI Reference | 2025.1

# p4 switch (graph)

Switch to a different branch, or create a branch.

## Syntax

    p4 switch [ -a | -n repo ] branch
    p4 switch -c [ -a | -n repo ] branch
    p4 switch -d [ -a | -f | -n repo ] branch
    p4 switch -l

Syntax conventions

## Description

The switch command moves the client to a different branch, optionally creating that branch.

Use the first form of the command to switch the current branch for your client.

## Options

`-l` | List the branches
`-a` | Applies for clients having more than one repo. All repos that contain the specified branch switch to it. Repos that do not contain the specified branch remain on their current branch.
`-c` | Create the specified branch and switch to that branch.
`-f` | Force the deletion of a branch. This option is required when a branch was not merged to the default branch.
`-n` | Named repo. For example, to create a branch by specifying a named repo:
    p4 switch -c -n //gd1/repo2 dev
    Branch refs/heads/dev created in repo //gd1/repo2.
`-c -a` | Create the specified branch and switch all repos to that branch. Example: `p4 switch -c -a branch2`
`-d` | Delete the specified branch.
`-d -a` | Delete the specified branch on all repos. Example: `p4 switch -d -a branch2`
`-d -n` | Delete the specified branch on the specified repo. Example: `p4 switch -d -n //graphDepot/repo2 branch2` We recommend that you not delete the branch you are currently on because this detaches your current branch HEAD from any tag or branch. This means your commit is unnamed and can be removed by a `git gc` (garbage collection).

Your search for returned results