Perforce Concepts
- Depot: folders on the Perforce server
- Workspace: defines a mapping of files between the server and client which is stored on the server and can be edited.
- Changelist: a list of files to be watched for changes (Perforce doesn't watch files automatically like Git)
- P4V: GUI client application to talk to Perforce server
- Checkout: the action of marking a file to be in the changelist so it can be edited (otherwise all files are read-only)
- Sync: download files from depot to local file system
- mainline: master branch equivalent of of Git
- streams: similar to branches on Git
Icon meanings:
- Green circle: you have the most current version
- Check mark: someone is working on this file
- Red X: file will be deleted
GUI navigation:
- Workspace tab: shows checked out files
- Depot tab: shows all files on server
Finding the size of depot in P4: p4 sizes -s //depot/directory/... (* must include the ellipses)
Creating a new workspace: Depot tab > select create new workspace in dropdown > fill in the workspace name > fill in local folder to store the checkout > methods below:
- Method 1: select the depot(s) in the GUI > click Open
- Method 2: click on text editor symbol on right-hand side > use the text editor select the depots > click Open
- * Note the workspace name must be specific enough or P4V will not be able to creat the workspace and pop an error with "workspace name is to ambiguous". Try adding more numbers to the workspace name longer and more specific as a fix
Checkout:
- Method 1: right-click on depot in workspace > Get Latest revision
- Method 2: right-click on depot in workspace > Get revision > ensure get latests revision is selected
Force Sync: right-click on depot > Get revision > Check the box with "Force Operation"
Creating a changelist: pending tab > double click on default changelist > write a description > expand to see checked out files
Adding a newly created file to changelist:
- Create the new file in Windows Explorer
- Go to P4V and refresh (the file will appear but be unmarked)
- Right-click > mark for add > select changelist where the addition should be made
Adding a file to changelist:
- Method 1: drag the file you want to add to the changlist in the GUI
- Method 2: right-click on the file and select checkout
Deleting files:
- Locate the file to be deleted
- Right-click > mark for delete > select changelist where deletion should happen
- The file will be marked with red x meaning the file will be deleted in the commit
Revert local changes:
- Method 1: find the file to revert in the changelist > right-click > revert
- Method 2: find the file to revert in the changelist > Ctrl + R
Commit: select changelist to commit > right-click > submit > update commit msg
Shelving files:
- shelving files is a way to store files that are checked out without submitting to the stream/mainline
- can be used to share modified files for code review or discussion
- only checked out files can be shelved
- after Perforce 2013 the shelved files can be checked in directly, which was not possible before
- a shelved file cannot move changelists
- shelving files are not tracked or recorded like commits
- only the changelist owner can manage the shelved files
- Method:
- checkout the file(s) to a numbered changed list (not default)
- right click on file(s) and choose "shelve"
- click OK on the dialogue
Unshelving files:
- refresh workspace
- take care to resolve any potential conflicts on the shelved files
- navigate or use filters to find the shelf in the workspace (usually it's not the same machine)
- right click on the the shelf or shelved files and choose "unshelve files"
- click OK on the dialogue (if you get a conflict it's probably better to revert the local files to avoid error)