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 2014 Server Upgrade Runbook: Verify, Checkpoint, Restore, and Validate

This guide converts the original Perforce 2014 upgrade notes into a practical runbook for production admins. It covers pre-checks, checkpoint-based recovery, post-upgrade verification, and migration cautions.

Read More

Perforce Server Disk Cleanup and Repository Size Management: A Safe, Practical Playbook

Running out of storage on a Perforce (Helix Core) server can quickly become an availability risk. This guide shows a safer cleanup workflow: measure space first, compare options, then execute changes with minimal operational risk.

Read More

Perforce Interview Prep: Essential p4 Commands for Workspaces, Changelists, and Admin Tasks

A practical Perforce interview refresher focused on high-value commands and admin concepts from real usage. Learn how to query changelists, exclude files, use metadata options, and avoid risky data-removal mistakes.

Read More

Perforce Training Guide: Hands-On P4 Curriculum for Users, SCM Engineers, and Release Teams

This revised guide turns a legacy Perforce training announcement into a practical reference for planning team enablement. It summarizes the syllabus, lab workflow, core P4 command areas, and post-training adoption practices.

Read More

Perforce Backup Commands: Checkpoints, Journal Rotation, and Restore Workflow

This guide explains the core Perforce backup commands from the original post and how to use them in a practical backup and restore workflow. You will get a command reference, comparison tables, and ready-to-adapt examples.

Read More

Perforce Tools Explained: Clients, Servers, Plug-ins, and Utilities (Legacy 2012 Reference)

This updated reference explains the Perforce tools listed in the original 2012 post, what each component does, and how they fit together. It also includes a practical p4 CLI workflow and cautions for legacy or renamed components.

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