Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Perforce P4 Command Reference: Core CLI Commands, Workflow, and Examples

Perforce (Helix Core) has a broad command-line interface, and this guide is for engineers who need a fast, reliable command reference while working. It covers the core workflow, what key commands are used for, and a cleaned command list preserved from the original post.

Originally published on 2010-11-25; fully revised and updated.

This revision is based on the original post, Basic Perforce Command – P4 Command Reference, with improved structure and practical examples.

Perforce command reference from original article

Perforce command workflow at a glance

This is the typical lifecycle for a basic P4 change: authenticate, sync, open files for change, resolve when needed, and submit.

flowchart TD
    A[Set P4PORT P4USER P4CLIENT] --> B[p4 login]
    B --> C[p4 sync]
    C --> D[Open files for add delete integrate]
    D --> E[p4 resolve]
    E --> F{Conflicts left}
    F -- yes --> E2[Resolve again]
    E2 --> F
    F -- no --> G[p4 submit]
    G --> H[Changelist stored in depot]

Quick start: connect and verify your workspace

Before editing or submitting, verify server connection, identity, and workspace context.

export P4PORT=perforce.example.com:1666
export P4USER=alice
export P4CLIENT=alice_ws

p4 login
p4 info
p4 clients
p4 sync //depot/main/...Code language: JavaScript (javascript)

Command comparison for everyday work

Use this quick comparison when deciding which command to run next.

TaskPrimary commandWhat it doesTypical follow-up
Bring workspace up to datep4 syncCopies files from depot to workspacep4 have, then edit/add/delete
Start a new filep4 addOpens file for addition to depotp4 change, p4 submit
Remove a tracked filep4 deleteOpens file for deletion from depotp4 submit
Merge or branch workp4 integrateOpens files for branching or mergingp4 resolve, p4 submit
Handle merge conflictsp4 resolveResolves differences between revisionsp4 submit
Undo local pending changesp4 revertDiscards changes to opened filesp4 sync if needed
Publish pending workp4 submitSends open file changes to depotp4 changelists, p4 describe

Example: create and submit a basic changelist

This example shows a small add/delete change and submission through a numbered changelist.

p4 sync //depot/main/...

p4 add docs/release-notes.txt
p4 delete config/old.properties

p4 change
# Note the changelist number created in the editor

p4 submit -c 12345Code language: PHP (php)

Example: integrate and resolve

p4 integrate //depot/release/... //depot/main/...
p4 resolve
p4 submitCode language: JavaScript (javascript)

Basic P4 command reference

The table below preserves the original command coverage and descriptions, cleaned for readability.

CommandDescription
p4 addOpen file(s) in a client workspace for addition to the depot.
p4 adminPerform administrative operations on the server.
p4 branchCreate or edit a branch specification and its view.
p4 changeCreate or edit a changelist specification.
p4 changelistsList submitted and pending changelists.
p4 changelistCreate or edit a changelist specification.
p4 clientCreate or edit a client workspace specification and its view.
p4 clientsList all client workspaces currently known to the system.
p4 deleteOpen file(s) in a client workspace for deletion from the depot.
p4 depotCreate or edit a depot specification.
p4 depotsDisplay a list of depots known to the Perforce server.
p4 describeProvides information about changelists and the changelists’ files.
p4 groupsList groups of users.
p4 groupAdd or delete users from a group, or set maxresults, maxscanrows, and timeout limits for members of a group.
p4 haveList files and revisions that have been synced to the client workspace.
p4 infoDisplay information about the current client and server.
p4 integrateOpen files for branching or merging.
p4 integratedShow integrations that have been submitted.
p4 jobCreate or edit a defect, enhancement request, or other job specification.
p4 jobsList jobs known to the Perforce server.
p4 labelCreate or edit a label specification and its view.
p4 labelsDisplay list of defined labels.
p4 lockLock an opened file against changelist submission.
p4 loginLog in to a Perforce server by obtaining a ticket.
p4 logoutLog out of a Perforce server by removing or invalidating a ticket.
p4 passwdChange a user’s Perforce password on the server.
p4 renameRenaming files under Perforce.
p4 resolveResolve conflicts between file revisions.
p4 revertDiscard changes made to open files.
p4 setSet Perforce variables in the Windows registry.
p4 submitSend changes made to open files to the depot.
p4 syncCopy files from the depot into the workspace.
p4 tagTag files with a label.
p4 triggersEdit scripts that run conditionally for submits, form updates, or external authentication integration.
p4 userCreate or edit Perforce user specifications and preferences.
p4 usersPrint a list of all known users of the current server.
p4 verifyVerify that server archives are intact.
p4 workspaceCreate or edit a client workspace specification and its view.

Best practices and common pitfalls

  • Run p4 info before major operations to confirm server, user, and workspace context.
  • Use numbered changelists for anything non-trivial so you can track and review changes cleanly.
  • Sync before integrate/resolve cycles to reduce avoidable conflicts.
  • Use p4 have when troubleshooting version drift between local files and depot state.
  • Treat admin-level commands (p4 admin, p4 verify, p4 triggers) as controlled operations.
  • When uncertain about syntax on your server version, check p4 help <command>.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Perforce p4 Command-Line Reference: Daily Commands, Changelists, Sync, and Merge Workflow

A practical p4 command reference for engineers who work in Perforce environments. Learn core commands, how they fit into the change lifecycle, and safer patterns for submit and merge operations.

Read More

Perforce Quick Facts: Clients, Server Components, Integrations, and CLI Workflow

A practical Perforce quick reference for DevOps teams, covering clients, server components, legacy integrations, and utility tools. Includes a simple architecture diagram and example CLI workflow commands.

Read More

Perforce p4 Command-Line Cheat Sheet: Query, Sync, Integrate, and Admin Workflows

A practical Perforce CLI reference for choosing the right p4 command quickly. Covers data-mining commands, workspace flow, revision syntax, branching, labels, and admin tasks.

Read More

Perforce Triggers Guide: Types, Execution Order, and Practical Patterns

Perforce triggers let you enforce workflow rules and launch automation directly from the server. This revised guide explains trigger types, execution order, trade-offs, and practical configuration patterns.

Read More

Step by step guide on PerforceDFiles Tool | Perforce Tutorial

Step-by-Step Guide on PerforceDFiles Tool PerforceDFiles is a diagnostic tool used in Perforce Helix Core (P4) to list, analyze, and delete orphaned or corrupted files from the…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x