Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 Server Administration Documentation | 2025.2

# Distributed development using Fetch and Push

The following sections describe how to use the `p4 fetch` and `p4 push` commands to share code between distributed sites.

Consider this scenario. The gaming company, Ukko Productions, has offices in France, Japan, and the USA. Each site develops code for a different component but might share code for widgets in such components. The developers at each site use `p4 submit` to store their code in the depot directory for their local site. France developers use `//depot/France-dev/`, Japan developers use `//depot/Japan-dev/`, and USA developers use `//depot/USA-dev`.

| To make its widget code available to Japan and the USA, France developers use `p4 push` to copy code into drop directories on the servers in Japan and the USA. (Alternatively, Japan developers and USA developers could use `p4 fetch` to copy code from France developers into their drop directories.) The Japan developers and USA developers merge the widget code from France developers into their respective `dev` directories using `p4 merge`. Japan developers and USA developers can then customize the widget for their own purposes, without sharing these customizations with the France developers. If Japan developers have a subset of changes to share with France developers, Japan developers use `p4 push` to copy this code into the drop location on the France server for Japan developers, `//depot/code-dropJapan/...` Similarly, if USA developers have a subset of changes to share with France developers, USA developers use `p4 push` to copy this code into the drop location on the France server for the USA developers, `//depot/code-dropUSA/...` (Alternatively, France developers could use `p4 fetch` to obtain the code and drop it into the appropriate locations.) France developers merge the code from Japan developers and USA developers into the `dev` directory for France developers, `//depot/France-dev/...`, by using `p4 merge`.

## Configuring the remote specifications

For the `p4 push` and `p4 fetch` commands to work properly, each of the three servers must have properly configured remote specifications.

Remote specifications determine:

- which remote servers a local server can fetch from or push to

- which files will be fetched and pushed.

The `DepotMap` field defines the mapping between the local depot on the left side, and the remote server depot on the right side. For example:

    DepotMap:
        //depot/code-dropFrance/... //depot/France-dev/...

where `//depot/code-dropFrance/...` is on the local server and maps to `//depot/France-dev/...` on the remote server.

Because Japan developers fetch from or push to the server for France developers, the remote spec for Japan developers is:

    RemoteID: ServerFrance
    Address: ServerFrance:1666
    DepotMap:
      //depot/code-dropFrance/... //depot/France-dev/...
      //depot/Japan-dev/... //depot/code-dropJapan/...

Because USA developers fetch from or push to France’s server, the remote spec for USA developers is:

    RemoteID: ServerFrance
    Address: ServerFrance:1666
    DepotMap:
      //depot/code-dropFrance/... //depot/France-dev/...
      //depot/USA-dev/... //depot/code-dropUSA/...

Because France developers fetch from or push to Japan developers, the remote spec for France developers is:

    RemoteID: ServerJapan
    Address: ServerJapan:1666
    DepotMap:
      //depot/France-dev/... //depot/code-dropFrance/...
      //depot/code-dropJapan/... //depot/Japan-dev/...

Because France developers also fetch from or push to USA developers, a second remote spec for France developers is:

    RemoteID: ServerUnitedStates
    Address: ServerUnitedStates:1666
    DepotMap:
      //depot/France-dev/... //code-dropFrance/...
      //depot/code-dropUSA/... //depot/USA-dev/...

    To learn more, see:

- Remotes, an overview.

- The `server.allowpush` and `server.allowfetch` configurables in the P4 CLI Reference .

Your search for returned results