How to add a file in shelved change list in Perforce

perforceversion control

I edited a file and then shelved the changes in it with shelved changelist X. Now I edit another file. How can I add this file in already existing shelved changelist X or generate a new changelist containing changes in both files?

Thanks.

Best Answer

You don't have to unshelve, as @Dennis suggests, although that may be one way to do it.

For an unopened file you wish to add to an existing shelf, simply open that file into your existing shelve's changelist. For example, if your shelf is identified by changelist #1729, then do

p4 edit -c 1729 forgot_to_shelve.py

Then, shelve it:

p4 shelve -c 1729

If it turns out that the file already exists in the shelf but you wish to update it, then as usual, add -f:

p4 shelve -c 1729 -f

For a file that's currently opened that you wish to add to your existing shelf, you would first reopen that file into your existing shelf's changelist, before shelving as above:

p4 reopen -c 1729 forgot_to_shelve_and_currently_opened.py
p4 shelve -c 1729

Reference:

In order to add a file to a pre-existing shelve, the file must first be opened in the shelve's changelist; use p4 reopen to move an opened file from one changelist to another.

p4 shelve // Perforce 2013.3: Command Reference