Perforce (P4)版本控制使用指南
以下为P4常规和一些必要操作
如何达到同步?本质就是需要告诉P4你干了什么,然后P4再别人的机器上模拟你所做的操作
操作的宗旨
- 如果想让别人知道你的操作,就需要去主动通知✘3
1、登录账号密码
相关信息会在入职手册里面提供,确保IT已经给你开好相关工程权限
![7643202-ddab3c8f85ae15b4.png](https://img-blog.csdnimg.cn/img_convert/2b9630795870cdacf3e9ebe9045332ce.png)
2、更改密码
第一次登录时,IT会提供一个随机密码,如果需要更改密码,在Connection/Change Password中修改
![7643202-8de7a16e7b90d2b5.png](https://img-blog.csdnimg.cn/img_convert/7497169da717a5fb6e931a7144c47461.png)
3、拉取文件
选择需要拉取的目录右键点击Get Lastest Revision,这样就可以拉取到服务器上的最新文件了
![7643202-154d516129eb1162.gif](https://img-blog.csdnimg.cn/img_convert/95d871a01766c235ecaa156dff5143d5.gif)
4、添加新文件
如果在工程目录中添加了新文件,而且也想让别人可以用到,那就要告诉服务器我需要添加一个文件(Mark for add),然后并确认(submit)
![7643202-0f6620f78f0f61a9.gif](https://img-blog.csdnimg.cn/img_convert/d961b26db86c11cbc9250c8140d96d95.gif)
![7643202-2a20cee1ea77ae0b.png](https://img-blog.csdnimg.cn/img_convert/ab6db6c01d8aec89de8ae2353874842c.png)
5、删除新文件
和添加文件类似,不过这次右键点击要删除的文件或者和文件夹,选择mark for delete
![7643202-f71d4fa5897d0ad5.gif](https://img-blog.csdnimg.cn/img_convert/010831da8d140af6e3c7a56ade75317f.gif)
6、修改内容并注意
注意:查看某人是否正在check文件(编辑中)被别人check的情况下后会蓝色对号提示,如果锁定的话会有锁图标
![7643202-64ab2ea2fcfce2f7.png](https://img-blog.csdnimg.cn/img_convert/dd04bc7d0887c24ccd94f0ace6afd84f.png)
![7643202-bd1aab9216e08537.png](https://img-blog.csdnimg.cn/img_convert/c69e2c56e3f1a58e1e7c263f10f1bdb4.png)
7、锁定解锁
锁定的文件可以check out 并修改,但是无法提交
![7643202-6d0023d30c818462.png](https://img-blog.csdnimg.cn/img_convert/b50796736598e5ba0bcf00da1376493e.png)
![7643202-c115e254904548d1.png](https://img-blog.csdnimg.cn/img_convert/ce15f96c636e811ed17dc16aef986777.png)
8、重置
如果有文件进行了修改,但是想还原,就可以使用revert功能,
![7643202-88fe7d87cd5fd795.png](https://img-blog.csdnimg.cn/img_convert/b3c36e685b320f51a4d4dd355d545082.png)
9、Revert和 Revert Unchange files区别
Revert是一律进行重置操作,而Revert Unchange files是如果没有进行修改则进行revert(恢复)
![7643202-315069fbc65375cf.png](https://img-blog.csdnimg.cn/img_convert/9d92e0a5f23d882d8d153552bffcdf63.png)
10、有其他人提交新的版本
![7643202-f8ced04748b463c6.png](https://img-blog.csdnimg.cn/img_convert/8ee2bc429e15e3c3a9fffd54ab2749e8.png)
11、查看当前版本号
前面的数组是当前的,后面的是服务器最新的版本号
![7643202-388bd4f9356b44a7.png](https://img-blog.csdnimg.cn/img_convert/3f0f7962b99752f95d6b69c63eef60f5.png)
12、发现冲突
这是因为同一个文件多人在同时编辑,并且有人提交了新的版本
![7643202-54c6dc1357a54416.png](https://img-blog.csdnimg.cn/img_convert/ff83e7fc8380cee10680b22085066a68.png)
13、现有版本进行文件差异对比
会对差异的地方进行着色,左侧为服务器谁,右侧为自己的。但是有些文件无法比较,excel,图片,预制体等
![7643202-5a78b8c26443b1eb.png](https://img-blog.csdnimg.cn/img_convert/4b9b1d88a72e86959dad702b9a88b4d0.png)
![7643202-4b16dd8b07d85c6f.png](https://img-blog.csdnimg.cn/img_convert/c614694ef23108e331eae6afde74be21.png)
14、某版本之间进行文件差异性对比
![7643202-adff921ee5284f8f.png](https://img-blog.csdnimg.cn/img_convert/bdabdf887064df039bb21d87de4f998a.png)
![7643202-1a75b47499dc9cef.png](https://img-blog.csdnimg.cn/img_convert/6cbb346cbbfdf476af49422b7ed1f91b.png)
15、解决冲突
最后用谁的你们可以pk一下
![7643202-2db91587587e856b.png](https://img-blog.csdnimg.cn/img_convert/a0a075a965ef71f6a072485b00d24620.png)
![7643202-afe99b87c1ff7d55.png](https://img-blog.csdnimg.cn/img_convert/4680025ff039f12a5d369ad97476b9f9.png)
对于一些可以合并的文本文件(txt,code)可以执行合并操作
![7643202-9d2300069a904f86.png](https://img-blog.csdnimg.cn/img_convert/02addfa5921f611b2cb8d6913c458d7b.png)
![7643202-815fbdca5d775b82.png](https://img-blog.csdnimg.cn/img_convert/9839e305225cda88be917135cfca2b06.png)
强行合并,内容需要自定修改并删除注释
![7643202-e1cb2b6541bf98a1.png](https://img-blog.csdnimg.cn/img_convert/4b4ea744167512948d626038a2612701.png)
![7643202-03762f54ae991fa0.png](https://img-blog.csdnimg.cn/img_convert/0b61fd73defbfd01f718f6cc25888f66.png)
16、查看提交记录
选中需要查看记录的文件或者文件夹,点击history视图,里面有各个版本的提交时间和提交人
![7643202-ea4c9507d131456e.png](https://img-blog.csdnimg.cn/img_convert/8ede75215e6abbe625937513b938ee99.png)
17、恢复误删除文件
选中对应的文件夹,点击reconcile offline work,进行对比,会显示出这个文件夹内的文件和服务器上的文件都有哪些变动(修改、增加、删除),点击reconcile按钮上传对应的差异性操作,然后在对应的pending列表恢复操作就可以可
![7643202-8fca7d3bfeb6a426.png](https://img-blog.csdnimg.cn/img_convert/8240954767d0b5a303b6279087ab1e17.png)
![7643202-6fc9fcf9dde818be.png](https://img-blog.csdnimg.cn/img_convert/8b618b0587f23676a75ada5910a84dc3.png)
![7643202-4f060d7327403d29.png](https://img-blog.csdnimg.cn/img_convert/903633f7528ade5e9770c8a52d889c4f.png)
18、刷新
修改文件有时候会有短暂延迟,所以看不到新文件提交的时候可以点击刷新按钮(一般用不到)
![7643202-37eb71cf03d9a0c5.png](https://img-blog.csdnimg.cn/img_convert/f0bf9ecd205af0827318d5479994cfef.png)
19、打开对应新的视图,可以点击顶端工具栏中的view选择对应视图即可
如果右侧的视图关闭后需要重新开启
![7643202-b4c0182e1d7a3343.png](https://img-blog.csdnimg.cn/img_convert/a1aeab0c427cf4fada581f89498fda4a.png)
20、添加工作区(workspace)
应对一下一些文件模型拉取不了,就用重启大法,点击workspace下面的工作空间,选择新建,然后在弹出的面板中选择路径和对应的新命名就OK了
![7643202-dff5c091a8182faa.png](https://img-blog.csdnimg.cn/img_convert/9214097961f3f62a20243c161472dd29.png)
![7643202-251c929b50bce203.png](https://img-blog.csdnimg.cn/img_convert/483092c17febcfc99195dd7b3a3de032.png)
21、删除工作区
保持整洁,应对强迫症患者
![7643202-eb8d7746f8f91664.png](https://img-blog.csdnimg.cn/img_convert/dbee4843d95ffa34562ca1c13368b340.png)
![7643202-f43b62cfa9d6eaa2.png](https://img-blog.csdnimg.cn/img_convert/7d433cb8cf88140317c251b774202f22.png)
22、移动和重命名
移动文件和重新命名需要通过P4操作,这样服务器才能知道我们的改动,本地操作无效
![7643202-04da06a34af2404f.png](https://img-blog.csdnimg.cn/img_convert/ae002fb9087027e7a489290fca0a31ef.png)
![7643202-1a2040bd93d88579.png](https://img-blog.csdnimg.cn/img_convert/f53b3f8e4fa232516dcfdcd6d513eed9.png)
![7643202-704b60b9b78f2bfe.png](https://img-blog.csdnimg.cn/img_convert/fabd7369322555c31689358a8a4fcb42.png)
23、删除无用PendingList
及时清理,防止堆积
![7643202-e8c1c114fd4f7016.png](https://img-blog.csdnimg.cn/img_convert/526a77485e4783827f0e24eb0b56d9d1.png)
24、恢复到指定版本
此操作可将文件恢复到历史记录中指定版本当时提交的状态
第一种方式
Get Revision
第二种方式
![7643202-e75c994a1524928d.gif](https://img-blog.csdnimg.cn/img_convert/d921994d0a2556c586d7482374b44a65.gif)
![7643202-002ce4493c447834.png](https://img-blog.csdnimg.cn/img_convert/804ce26a5b28968bae1250b396f709e1.png)
FAQ (常见问题解答)
错误:Translation of file content failed near line 1 file
,多数是编码方式造成的问题
有时会出现错误Translation of file content failed near line 1 file D:\p4\depot\I_P_021_D_game\client\testbed\xiaofeng.he\URP_Shading\com.unity.render-pipelines.core\LICENSE.md
这时候要查看对应的编码方式是否正确
![7643202-df83a0f7b195b849.png](https://img-blog.csdnimg.cn/img_convert/9027734ca328cb433089e79299daae4e.png)
![7643202-7e4acfd700e978d7.png](https://img-blog.csdnimg.cn/img_convert/2dfa8e8530beaf84e8d2195910a0e04e.png)
本文转载于:https://blog.csdn.net/su9257/article/details/103454315