Can you “ignore” a file in Perforce?

后端 未结 10 503
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 19:35

I sometimes use the feature \'Reconcile Offline Work...\' found in Perforce\'s P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot.

10条回答
  •  时光取名叫无心
    2020-11-29 20:02

    Yes, But.

    Perforce version 2012.1 added a feature known as p4ignore, inspired by Git. However the Perforce developers made a change to the behaviour, without justification, that happens to make the feature a lot less useful.

    Whilst Git takes rules from all .gitignore files, Perforce doesn't know where to look until you specify a filename in an environment variable P4IGNORE. This freedom is a curse. You can't hack on two repositories that use different names for their ignore files.

    Also, Perforce's ignore feature doesn't work out the box. You can set it up easily enough for yourself, but others don't benefit unless they explicitly opt-in. A contributor who hasn't may accidentally commit unwelcome files (eg. a bin folder created by a build script).

    Git's ignore feature is great because it works out the box. If the .gitignore files are added to the repository (everyone does this), they'll work out the box for everyone. No-one will accidentally publish their private key.

    Amusingly, the Perforce docs shows '.p4ignore' as an example ignore rule, which is backwards! If the rules are useful, they should be shared as part of the repository.


    Perforce could still make good on the feature. Choose a convention for the file names, say p4ignore.txt, so the feature works out the box. Drop the P4IGNORE environment variable, it's counterproductive. Edit the docs, to encourage developers to share useful rules. Let users write personal rules in a file in their home folder, as Git does.

    If you know anyone at Perforce, please email them this post.

提交回复
热议问题