MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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 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 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

Perforce Changelist Numbers Explained: Default, Numbered, and Submit-Time Renumbering

Perforce changelist numbers are simple once you understand when numbers are assigned and why pending changelists can be renumbered at submit time. This guide clarifies the default changelist, numbered changelists, and practical p4 command usage.

Read More

Perforce Slow Sync Troubleshooting Guide: Latency, DNS, and Storage Bottlenecks

Slow Perforce syncs are often caused by latency, DNS lookups, wildcard handling on Windows, or storage placement issues. This guide gives you a practical workflow, command checks, and remediation paths to isolate the real bottleneck.

Read More

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

A cleaned, structured reference of basic Perforce (P4) commands for daily Helix Core work. Includes a workflow diagram, command comparisons, and practical CLI examples.

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
1 month ago

The p4 duplicate command can be useful when teams need to copy Perforce data for specific workflows. Before using it, it is important to understand which files and revisions will be affected. Testing the command in a safe workspace helps prevent accidental changes to shared work. Clear naming and documentation also make duplicated content easier to track later. Checking the result afterward helps ensure the copy matches the intended source.

1
0
Would love your thoughts, please comment.x
()
x