Reputation: 631
I want to checkout an older specific version from the command line, How can I do that ? couldn't find any help in documentation in p4 docs.
Upvotes: 0
Views: 3196
Reputation: 71574
The word "checkout" isn't standard terminology in Perforce; if you're coming from git then what you call "checkout" is "sync" (and also "revert" and "switch" because of how badly "git checkout" is overloaded), but "checkout" is also sometimes used to refer to "opening" a file in Perforce, which is sort of like "staging" in git but not exactly.
I'll describe how to both "sync" and "open" a file and you can figure out which operation corresponds to whatever you're trying to do.
To sync a file from the depot into your workspace, use the p4 sync
command:
p4 sync FILE#VERSION
If no VERSION
is specified, the default is #head
(the latest). If no FILE
is specified, the entire workspace is synced.
After a file is synced, it is read-only in your workspace; you can view the file, build, test, etc, but the file itself may not be modified until it's opened.
To open a file for edit (so that you can make changes to it and then submit those changes to the depot), use the p4 edit
command:
p4 edit FILE
Whatever version has been synced to your workspace is the one that is opened for edit by this command. If you want to submit
your change, you will need to resolve
the later changes first, but you have the option when resolving of discarding those changes. (If your primary intent is to discard specific changes, you can do this more directly with the undo
command.)
You can view currently-synced files with the p4 have
command, and currently-open files with the p4 opened
command.
Upvotes: 1