Skip to content

Instantly share code, notes, and snippets.

@ben-doyle
Last active July 5, 2024 03:47
Show Gist options
  • Save ben-doyle/27fd95c5fcdb87386ac86439100ee787 to your computer and use it in GitHub Desktop.
Save ben-doyle/27fd95c5fcdb87386ac86439100ee787 to your computer and use it in GitHub Desktop.
Perforce for git users.

Understanding Perforce (as a git user).

Commands

Git Perforce Command Line P4V Notes
git pull p4 sync get latest revision
n/a p4 update ? Get latest revision without overwriting files that have been changed.
git checkout p4 edit checkout You plan to change a file from the version control system
git commit p4 submit submit
git push n/a n/a No perforce equivalent. There is no concept of a pure local submit in Perforce.
git status p4 status ?
git stash p4 shelve
git blame p4 annotate

Terminology

Git Perforce
Git Perforce
Repository Depot
Local Repository Workspace

Sample workflow

1 - Get the files from the server

cd /Users/turtle/work
p4 sync

2 - Checkout the file you want to work on and modify it

p4 edit main/foo; 
echo cake >> main/foo

3 - Submit it to the server

p4 submit -d "A trivial edit"

Useful Commands

  1. Revert all changes
 p4 revert //...
  1. Restore workspace files to match the state of corresponding depot files.
p4 clean

Resources:

  1. https://stackoverflow.com/questions/17267218/perforce-for-git-users
@kfsone
Copy link

kfsone commented Dec 1, 2022

I think there are some misunderstandings of both perforce and git here. In some ways they're more alike than it seems.

Think of it like this:

When you just map a depot to a local workspace, that's like having a ".svn" folder - a local checkout of remote files.

But when you use the "local server", it's really more like having a ".git" folder where you have the ability to create all your own streams and branches and files and version numbers...

So p4 totally has a concept of push: http://ftp.perforce.com/perforce/r16.2/doc/manuals/cmdref/p4_push.html

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