How to create a perforce empty changelist from command line How to create a perforce empty changelist from command line windows windows

How to create a perforce empty changelist from command line


If you're using the command line interactively, the regular "p4 change" command is the way to go:

p4 change

This opens the changelist spec in your editor so you can fill it out, and saves the changelist when you save the file in your editor and exit it.

If you're scripting, you can use "p4 change -i" but you need to make sure to feed it a valid changelist form via stdin. The "p4 change -o" command gives you the same form you get from "p4 change" (via stdout instead of your editor), so all that's left is to fill out the description and/or modify the list of files to be included. The --field option is useful here:

p4 --field "Description=My pending change" change -o | p4 change -i

If you want the new changelist to be empty rather than inheriting open files from the default changelist, blank the Files field:

p4 --field "Description=My pending change" --field "Files=" change -o | p4 change -i


Just using "p4 change" will open up the change form in the editor and upon saving a numbered change is created


My p4 doesn't understand --fields option. The following worked for me.

#Powershell commandletecho "Change: new`nClient: <client-name>`nUser: <user-name>`nStatus: new`nDescription: NewCL"|p4 change -i

Replace the items in <> brackets.

Here is the output of just the echo part.

#Powershell commandletPS C:\Users\sahil> echo "Change: new`nClient: <client-name>`nUser: <user-name>`nStatus: new`nDescription: NewCL"Change: newClient: <client-name>User: <user-name>Status: newDescription: NewCL

As you can see, the echo command just constructs a formatted string which p4 change -i accepts.

`n is used above for new line.

Note that I have excluded Files, as I wanted the change list to be empty.

Update - I updated my perforce installation and now p4 understands --fields option.