p4 changelist cheatsheet

A changelist in Perforce is identified by an unique number and contains a list of modified files and a description (among other things). When you inform Perforce that you have created a file, deleted a file or modified a file, such changed files are by default added to a default changelist that has no changelist number.

  • To create a changelist by grabbing the files in the current default changelist:
$ p4 change

This opens your default editor to a temporary text file showing an empty description and the list of files from the default changelist. You have to use the editor and provide a description. If you do not want some of the files to be in the changelist you are creating, you can delete those lines in the editor. Once you save the file, the changelist is created with a unique number identifying it. After this command ends, p4 prints out its changelist number, say 123456.

Note that this command moves all the files in the default changelist to the new changelist you created. That is, unless you removed a few of them while creating the changelist.

  • To view all the details of an existing changelist 123456:
$ p4 change -o 123456
  • To add a new file to an existing changelist 123456:
$ p4 reopen -c 123456 joe/foobar.cpp

Description

  • To view the description of a changelist:
$ p4 describe 123456
  • To edit the description of an existing changelist 123456:
$ p4 change -u 123456

Shelve

  • To shelve the files from a changelist 123456:
$ p4 shelve -c 123456
  • To list the files in a shelved changelist 123456:
$ p4 describe -s -S 123456
  • To update a shelved changelist 123456 with newly updated files from disk:
$ p4 shelve -f -c 123456
  • To update a shelved file with a particular changed file from disk:
$ p4 shelve -f -c 123456 foobar.cpp
  • To delete the shelved files of a changelist:
$ p4 shelve -d -c 123456
  • To delete a few files from a shelved changelist 123456:
$ p4 shelve -d -c 123456 joe/foo.cpp joe/foo.h

Unshelve

  • To unshelve the files that were shelved from a changelist 123456 back to the same changelist:
$ p4 unshelve -s 123456 -c 123456
  • To unshelve the files that were shelved from a changelist 123456 back to a different changelist 789012:
$ p4 unshelve -s 123456 -c 789012
  • To unshelve the files that were shelved from a changelist 123456 back to the default changelist:
$ p4 unshelve -s 123456

Submit

  • To create a changelist from the default changelist and submit it to your branch in the depot:
$ p4 submit
  • To submit a changelist 123456 to your branch in the depot:
$ p4 submit -c 123456
Advertisements

One thought on “p4 changelist cheatsheet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.