Skip to content

Instantly share code, notes, and snippets.

@terrehbyte
Created March 28, 2020 01:02
Show Gist options
  • Save terrehbyte/b5098b856cd21f3122c2b12bfd63e804 to your computer and use it in GitHub Desktop.
Save terrehbyte/b5098b856cd21f3122c2b12bfd63e804 to your computer and use it in GitHub Desktop.

P4 Revert Guide

Old, but Reliable

To revert someone else's files, you'd ideally know the $USER, $CLIENT, $CHANGE (optionally), and $FILESPEC.

  • $USER, the username as indicated by perforce
  • $CLIENT, also known as the workspace
  • $CHANGE, the number of the changelist (or default)
  • $FILESPEC, the file specification used to determine which or what pattern of files to apply this to
# Find the workspace host
p4 client -o $CLIENT

# Impersonate the user
p4 login $USER

# Revert the files as that user, on that workspace, on that machine
p4 -u $USER -c $CLIENT -H $HOST revert $FILESPEC

Source: How to delete a pending changelist in Perforce from an old workspace and offline machine (by admin access)

2015+ Server

If someone else has erroneously checked out a file (especially one with an exclusive-open mode) and has left for vacation, you can revert this on the CLI if you have administrative powers.

# Revert files on a given client
p4 revert -C $CLIENT $FILESPEC

# Optionally include a specific changelist to modify
p4 revert -C $CLIENT -c $CHANGELIST $FILESPEC

Source: Reverting Another User's Files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment