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.

How to Use `p4 duplicate` for a Perforce Branch Path Rename (Deep Rename)

If you need to change a depot branch path in Perforce (Helix Core) without losing history, p4 duplicate is the command designed for that job. This guide is for DevOps and SCM engineers who need a practical, low-surprise workflow for a rename-style move (often called a deep rename) and safe cleanup afterward.

Originally published on 2012-05-16; fully revised and updated.

p4-duplicate-command

What p4 duplicate solves

The original problem was: can a branch name/path be effectively renamed, similar to directory rename? The practical solution is to duplicate revisions from the old depot path to a new one, then optionally remove the old path.

Per the command help text cited in the original post, p4 duplicate mirrors source revisions into target revisions “as if they always existed,” including metadata and contents.

  • Duplicates revision content from source path to target path.
  • Mirrors changelist number, date, attributes, and contents (as described in the original help excerpt).
  • Duplicates integration records as well.
  • Requires target revisions not to already exist.
  • Requires target files not to be opened on any client.

Deep-rename workflow

flowchart TD
    A[Identify old depot path] --> B[Choose new depot path]
    B --> C[Run p4 duplicate]
    C --> D[Validate files and history]
    D --> E{Keep old path?}
    E -- Yes --> F[Leave source path in place]
    E -- No --> G[Run p4 obliterate -y on old path]
    G --> H[Update team configs and automation]

Command sequence

1) Duplicate old branch path to new branch path

p4 duplicate //depot/Jam/MAINds/... //depot/Jam/MAIN/...Code language: JavaScript (javascript)

This is the core rename-style step. Make sure the target path does not already contain the revisions you are creating, and that target files are not opened on any client.

2) Validate the duplicated path

p4 files //depot/Jam/MAIN/...
p4 filelog //depot/Jam/MAIN/...Code language: JavaScript (javascript)

Check that files are present at the new path and that expected history/integration lineage appears.

3) Remove the old path only if it is no longer needed

p4 obliterate -y //depot/Jam/MAINds/...Code language: JavaScript (javascript)

Warning: obliterate is destructive. Use it only when your retention policy, backup posture, and team process allow permanent removal.

4) Inspect built-in help for your server/client version

p4 help duplicate

Command comparison for rename-style branch moves

CommandPrimary purposeHow it fits this workflowRisk level
p4 duplicateCreate mirrored revisions at a new depot path, including metadata/integration records (per help excerpt)Main step for deep rename/path replacementMedium
p4 integrateIntegrate changes between branches/pathsNot a direct substitute for metadata-preserving duplicationLow to Medium
p4 obliterate -yPermanently remove files/history at a depot pathOptional cleanup after successful duplicationHigh

References

Original attribution: Perforce Support and community discussion thread:

http://maillist.perforce.com/pipermail/perforce-user/2010-November/027364.html

Best practices

  • Run the duplicate operation in a controlled window to avoid active opens on target files.
  • Validate with p4 files and p4 filelog before deleting anything.
  • Treat p4 obliterate -y as a governed operation with explicit approval.
  • Update workspace views, CI jobs, and documentation to the new depot path immediately after cutover.

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