Fetching and Pushing

Fetching and pushing lie at the heart of a collaborative distributed workflow; they enable users to perform a number of major tasks:

  • To copy changelists from a personal server to a shared server
  • To fetch changelists from a shared server that were pushed there by other personal servers
  • To obtain and work with a subset of a shared server’s entire repository.
  • To copy work between two personal servers

Administrators can also use fetching and pushing to copy changelists between shared servers.

Fetch and push are to the distributed versioning model what sync and submit are to classic Helix Server’s central server model.

Clone and fetch are supported by all replica types (readonly, build farm, forwarding replica, edge server, workspace server, standby, forwarding standby, etc.). All forwarding replica types (edge, forwarding, forwarding-standby, workspace) support push by automatically forwarding the push to the commit server. Replicas of type readonly, build farm, and standby refuse push.

The p4 fetch command copies the specified set of files and their history from a remote server into a local server. The p4 push command copies the specified set of files, and their history from a local server to a remote server. Both commands are atomic: either all the specified files are fetched or pushed or none of them are.

If a p4 push command fails after it has begun transferring files to the remote server, it will leave those files locked on the remote server. The p4 opened command will display locked, and the files cannot be submitted by any other user. If the p4 push command cannot be quickly retried, you can use the p4 unlock -r command to unlock the files on the remote server.

The p4 push command is not allowed if there are unsubmitted changes in the server from which you’re pushing; use p4 resubmit to resubmit those changes first, or discard the shelves with p4 shelve -d if they are not wanted. For more information on p4 unsubmit and p4 resubmit, see the example at Resolve conflicts by rewriting local history.

To monitor the progress of the fetch or push, pass the -I option to the command:

$ p4 -I fetch
$ p4 -I push