{"id":4,"date":"2019-07-15T14:19:50","date_gmt":"2019-07-15T14:19:50","guid":{"rendered":"https:\/\/openapex.org\/spaces\/software\/?p=4"},"modified":"2022-11-30T17:50:19","modified_gmt":"2022-11-30T12:20:19","slug":"getting-started-with-perforce-command-line","status":"publish","type":"post","link":"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html","title":{"rendered":"Getting Started with Perforce Command Line"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#1_Context\" >1. Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#2_Login_and_Sync_Workspace\" >2. Login and Sync Workspace<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#3_Create_and_Manage_Changelist\" >3. Create and Manage Changelist<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#4_Manage_Files_in_Changelist\" >4. Manage Files in Changelist<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#5_Shelve_or_Delete_a_Changelist\" >5. Shelve or Delete a Changelist<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mutesoft.com\/spaces\/software\/getting-started-with-perforce-command-line.html\/#6_Submit_a_Changelist\" >6. Submit a Changelist<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"1-context\"><span class=\"ez-toc-section\" id=\"1_Context\"><\/span><strong>1. Context<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Out of all source control systems I have used, I found Git extremely lightweight and easy to use. I am a huge Git fan. I prefer to use Git from the command line rather than using a user interface-based app. For the last couple of years, I have been working on a project that uses Perforce for source control. Perforce workflow is not much different from Git or any other source control system. So, I adopted it easily. However, I started using the &#8216;Perforce Helix P4V&#8217; user interface-based app for all my work, starting from syncing my local workspace to creating a change list, checkout, submit, etc. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized is-style-default\"><a href=\"https:\/\/openapex.org\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/openapex.org\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM.png\" alt=\"\" class=\"wp-image-696\" width=\"840\" height=\"482\" srcset=\"https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM.png 3360w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM-300x172.png 300w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM-1024x588.png 1024w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM-768x441.png 768w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM-1536x881.png 1536w, https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2020\/12\/Screenshot-2020-12-11-at-5.13.31-PM-2048x1175.png 2048w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption class=\"wp-element-caption\">Perforce UI<\/figcaption><\/figure>\n\n\n\n<p>I was not quite happy using another user interface that is always open on my laptop for Perforce operations. I knew about <code>p4<\/code> commands but I thought it is not good enough or at least not on par <code>git<\/code> cli. Recently, I thought let me try it and if it is not good always I can go back to the user interface. Believe me, I like <code>p4<\/code>. The <a href=\"https:\/\/www.perforce.com\/manuals\/cmdref\/Content\/CmdRef\/commands.html\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a> is very much elaborative with examples and above all, everything just works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-login-and-sync-workspace\"><span class=\"ez-toc-section\" id=\"2_Login_and_Sync_Workspace\"><\/span><strong>2. Login and Sync Workspace<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\n\nLogin and sync the local workspace with remote.\n\n<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Change directory to Perforce workspace\ncd workspace\n\n# Login\np4 login -a\n\n# Sync current workspace files\np4 sync &lt;workspace_path>\/...#head\n\n# Or simply execute\np4 sync<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-create-and-manage-changelist\"><span class=\"ez-toc-section\" id=\"3_Create_and_Manage_Changelist\"><\/span><strong>3. Create and Manage Changelist<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Create, list, and view the changelist.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Create a new changelist. Opens an editor where the template text can be modified\np4 change\n\n# Create a new changelist. Template content has to be supplied on console \np4 change -i\n\n# List my pending changelist. Valid status: pending, submitted, shelved\np4 changes -s pending -u &lt;user_id>\n\n# View details of a changelist\np4 describe &lt;changelist_number><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-manage-files-in-changelist\"><span class=\"ez-toc-section\" id=\"4_Manage_Files_in_Changelist\"><\/span><strong>4. Manage Files in Changelist<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Check out an existing file, add a new file to a changelist, view diff and submit a changelist.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Checkout files\np4 edit -c &lt;changelist_number> file\n\n# Add files\np4 add -c &lt;changelist_number> file\n\n# Delete files\np4 delete -c &lt;changelist_number> file\n\n# Revert a file\np4 revert -c &lt;changelist_number> file<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-shelve-or-delete-a-changelist\"><span class=\"ez-toc-section\" id=\"5_Shelve_or_Delete_a_Changelist\"><\/span><strong>5. Shelve or Delete a Changelist<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Shelve, unshelve files or delete a changelist.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Shelve files from a changelist\np4 shelve -c &lt;changelist_number>\n\n# Unshelve files from a changelist to a new different changelist\np4 unshelve -s &lt;changelist_number> -c &lt;new_changelist_number>\n\n# Delete a changelist\np4 change -d &lt;changelist_number><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-submit-a-changelist\"><span class=\"ez-toc-section\" id=\"6_Submit_a_Changelist\"><\/span><strong>6. Submit a Changelist<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>View file diff and submit a changelist.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"atomic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># View diff\np4 diff file\n\n# Submit a changelist\np4 submit -c &lt;changelist_number><\/pre>\n\n\n\n<p>The full list of <code>p4<\/code> commands are available here: <a rel=\"noreferrer noopener\" aria-label=\"perforce  (opens in a new tab)\" href=\"https:\/\/www.perforce.com\/manuals\/cmdref\/Content\/CmdRef\/commands.html\" target=\"_blank\">perforce <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> I have been working on a project that uses Perforce for source control. Perforce workflow is not much different from Git or any other source control system.<\/p>\n","protected":false},"author":2,"featured_media":696,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":" I have been working on a project that uses Perforce for source control. Perforce workflow is not much different from Git or any other source control system.","_seopress_robots_index":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[32],"tags":[35],"class_list":["post-4","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools","tag-perforce"],"_links":{"self":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/4","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":24,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":1315,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/4\/revisions\/1315"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media\/696"}],"wp:attachment":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}