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-Line Reference: Daily Commands, Changelists, Sync, and Merge Workflow

Originally published on 2010-05-13; fully revised and updated.

This guide is for DevOps engineers and developers who use the p4 command-line client with Perforce. It turns the original quick command list into a structured reference you can use in day-to-day work: opening files, managing changelists, syncing revisions, integrating branches, and submitting safely.

Source article: Most User P4 Command Line – P4 Commands Reference.

p4 command-line reference

How the p4 workflow fits together

Most teams follow a repeatable lifecycle: authenticate, sync, open files for add/edit/delete, review changelist content, resolve conflicts if needed, then submit.

flowchart TD
    A[Check server and workspace] --> B[p4 login]
    B --> C[p4 sync]
    C --> D{Work needed}
    D -- New file --> E[p4 add]
    D -- Modify file --> F[p4 edit]
    D -- Remove file --> G[p4 delete]
    E --> H[p4 change review]
    F --> H
    G --> H
    H --> I[p4 resolve when needed]
    I --> J[p4 submit]
    J --> K[p4 have or p4 sync verify]

Core p4 commands at a glance

CommandPrimary purposeExamplePractical note
p4 addOpen new file(s) for additionp4 add -t binary file.pdfCan override typemap with -t.
p4 editOpen existing file(s) for editp4 edit -t text+k doc/*.txtFile is checked out in workspace metadata.
p4 deleteOpen file(s) for deletionp4 delete //depot/READMEWorkspace file is removed immediately; depot changes on submit.
p4 revertDiscard pending file changesp4 revert //depot/…Returns open files to pre-opened state.
p4 changeCreate or edit changelist specp4 changeUse numbered changelists for better control.
p4 changelistsList pending/submitted changelistsp4 changelistsUseful before submit or cleanup.
p4 submitSend open file revisions to depotp4 submit -c 41Final depot update happens here.
p4 syncCopy depot files to workspacep4 sync //depot/proj1/…@21Supports revision and changelist targets.
p4 haveShow synced revisions in workspacep4 haveHelps verify client state.
p4 integrate (p4 integ)Open files for branch/mergep4 integ //depot/dev/… //depot/rel2/…Creates targets if they do not exist.
p4 resolveResolve file conflictsp4 resolveRun after integrate/merge steps.
p4 loginGet authentication ticketp4 loginNeeded before protected operations.
p4 infoDisplay client/server connection detailsp4 infoGood first diagnostic command.
p4 userCreate/edit/delete user specsp4 user -d sammyDeletion and edits may require elevated rights.
p4 adminAdministrative server operationsp4 admin stopRestricted to admin/superuser roles.

Command patterns you will use most

Add new files

Use p4 add to open files for addition. You can set file type, assign a changelist, or force-add a literal filename pattern.

p4 add -t binary file.pdf
p4 add -c 13 *
p4 add README ~/src/*.c
p4 add -f *.cCode language: JavaScript (javascript)

Edit, delete, and revert files

p4 edit -t text+k doc/*.txt
p4 delete //depot/README
p4 delete -c 40 file
p4 revert //depot/...

Manage changelists and submit

p4 change
p4 change -f 25
p4 changelists
p4 submit
p4 submit -c 41

Sync and inspect revision state

p4 sync
p4 sync file.c#4
p4 sync //depot/proj1/...@21
p4 haveCode language: PHP (php)

Integrate and resolve branch changes

p4 integ //depot/dev/... //depot/rel2/...
p4 resolve
p4 submitCode language: JavaScript (javascript)

Compare similar commands before you run them

CommandWhen to use itImmediate workspace effectDepot effect
p4 addNew file should be versionedFile marked open for addCreated in depot on submit
p4 editExisting tracked file is being modifiedFile marked open for editNew revision stored on submit
p4 deleteTracked file should be removedFile removed from workspace and opened for deleteDeleted in depot history on submit
p4 revertDiscard pending local changeOpen state removed; local edits discardedNo new depot revision
p4 submitFinalize pending changelistPending open files are closedDepot is updated with new revision metadata

User, authentication, and administration commands

These commands are commonly used during setup, troubleshooting, or admin workflows. Run administrative operations carefully, especially in shared environments.

p4 info
p4 login
p4 passwd
p4 user
p4 user joe
p4 user -d sammy
p4 admin stop

P4CONFIG for repeatable local setup

The original post mentions P4CONFIG. In practice, teams often use it to keep consistent local client settings. Keep secrets out of shared files and follow your organization policies.

export P4CONFIG=.p4config
p4 infoCode language: JavaScript (javascript)
P4PORT=perforce.example.com:1666
P4USER=your-user
P4CLIENT=your-workspace

Common pitfalls and best practices

  • Open files with p4 add, p4 edit, or p4 delete before editing workflow-critical files.
  • Prefer numbered changelists for multi-file work; avoid large, mixed default changelists.
  • Sync before integrate and before submit to reduce avoidable conflict resolution.
  • Use p4 have and p4 changelists to verify state before submit.
  • Be careful with wildcard patterns like *.c; shell expansion behavior can differ by environment.
  • Treat p4 admin stop as a controlled maintenance action, not a routine 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
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x