What is the p4 command equivalent to something like git/hg/bzr/svn status? (Hint: not `p4 status`)

Q: what is the perforce equivalent for the status command of other version control tools?

E.g. git status or hg status or bzr status or svn status? (Confusingly, cvs update -nq is the closest thing for that version control system.)

  • Cloning a git repo, and it already has a dirty working directory… Whaaaaa?
  • How to get rid of ESC[ characters when using git diff on Mac OS X Mavericks?
  • Git: Determining merge changes when no conflicts
  • Sourcetree: Find out if a branch is merged
  • How can I change the current repository I am connected to?
  • What is ObjectiveC.gcno? Should it be included in source code repository?
  • Hint: it is NOT p4 status. First, p4 status is not a read-only status command, but actually changes the state of the workspace – it actually adds local changes to a pending changelist. Second, p4 status does not tell you about files that are on pending changelists.

    It looks like some combination of p4 status and p4 opened is needed to get the bare minimum of what the other VCSes do in a single command.


    Most version control systems have a command that can quickly tell you the status of a workspace. Information such as:

    • what files are checked out for editing (if the VCS uses checkouts)
      • which of those checked out files have been locally changed or deleted
    • which files have been changed even though NOT checked out
      • e.g. which files may have changes that you want to merge
    • possibly which files are more recently updated in the repository than in your workspace
      • e.g. changes that you may want to merge into your workspace
    • what files are in the workspace but are not (yet) under version control
      • e.g. which files you may want to add to the version control system
      • or possibly add to your .hgignore/.gitignore/… ignore file patterns
    • what files are under version control but are not in the workspace
      • e.g. which files you may want to delete from your version control system
      • or which files you may have accidentally deleted

    Exactly what status information is provided depends on the VCS. E.g. Perforce is checkout based, but most modern version control tools are not.

    But… nearly all version control tools have a single, simple, command that will tell you such status.

    Except, apparently, perforce.

    … I may go on to provide examples of what git/hg/bzr/svn status do in a single command, but which perforce seems to require at least two commands to provide.

  • What are common pitfalls of timestamp based syncing?
  • How can I override the merge-base in a git merge?
  • Git diff without comments
  • Sync svn and mercurial repo
  • I'm trying to merge two different branches, but git tells me that everything is up-to-date
  • What can/should I do about this git gc error? (rm: cannot unlink pack Permission denied)
  • One Solution collect form web for “What is the p4 command equivalent to something like git/hg/bzr/svn status? (Hint: not `p4 status`)”

    I keep saying that I dislike answering my own question, but I am going to do this here. I welcome anyone who wants to share better solutions and scripts. I would especially welcome somebody showing me that this is unnecessary, that Perforce actually does have the equivalent of svn/git/hg/bzr status.

    —+ A: git/hg/bzr/svn status = p4 opened + p4 reconcile -n

    In perforce at least two separate commands seem to be required to approximate what other VCS tools do with a single command, to provide a quick summary of the status of the workspace wrt the depot:

    p4 opened – for a list of files that you have opened in the workspace

    p4 reconcile -n – for a list of files that are not opened wrt perforce, but to which you have made local changes.

    (p4 reconcile -n to say “make no changes.)

    —+ Suitable for an alias or quick typing

    I combine these as follows:

    p4 $P4OPTS opened
    p4 $P4OPTS reconcile -n | sed -e 's/ - / - RECONCILE TO MAKE: /'

    The sed part to better differentiate the status for files that perforce already has opened from the status of files not opened under perforce. But I note that this is unsafe, when a file may have the string ” – ” in its name.

    —+ Fancified

    Because I often want the local paths, I currently use the following shell script my-p4-status to give me something more like what I am used to from other VCSes’ status command:

    # Perforce lacks a single command to tell you the status of a workspace,
    # the equivalent of hg/bzr/git status.
    # Warning: "p4 status" is not actually a read-only query!!!
    # "p4 status" is more like "p4 reconcile" - it actually opens files to edit, add, or delete (-e -a -d)
    # p4 opened only reports on the status of files currently opened by Perforce
    # It is necessary to combine "p4 opened" and "p4 reconcile -n" to get a net overview.
    # TBD: convert to local file path, rather than depot path.
    # (Not a simple sed-xargs-p4_fstat pipeline)
    if [ "$1" == "-ztag" ] || [ "$1" == "-verbose" ]
    case $P4OPTS in
        p4 $P4OPTS opened
        p4 $P4OPTS reconcile -n
        echo '#### p4 opened - Perforce files already opened ###'
        p4 $P4OPTS opened
        echo '#### p4 reconcile -n --- local edits, not opened in Perforce.  Run p4 reconcile to actually open. ###'
        p4 $P4OPTS reconcile -n | sed -e 's/ - / - RECONCILE TO MAKE: /'

    —+ Better? Please Share!

    If you have anything better, please share.

    Git Baby is a git and github fan, let's start git clone.