Create a remote

Remotes are described by remote specifications or remote specs for short. To create a remote, run the p4 remote command. This puts the remote specification or spec into a temporary file and invokes the editor configured by the environment variable P4EDITOR. You then edit the file to specify depot mappings and other information. Saving the file creates the remote spec.

To modify the remote, invoke p4 remote with the remoteID of the remote you want to modify; make changes in the editor to the remote spec and then save the file.

Example

In the following example, we get a list of remotes from a shared server, clone from the shared server using one of those remotes, show the resulting remote in the personal server — with the p4 remotes command — and then demonstrate that the path listed in the remote spec corresponds to the path passed to the clone command.

  1. First, we query a shared server for a list of remotes:

    $ p4 -p perforce:1666 remotes
    bpendleton-dev  'To clone bpendleton's dev branch, use this remote spec. '
    h_dev localhost:1666 'Created by hmackiernan. '
    markm-remote2  'Created by markm. '
    mw-dvcs localhost:1666 '[dvcs] Map main server components.  Created by mwittenberg. '
    p4-client localhost:1666 'Created by cmclouth. '
  2. Then we choose a remote and pass it to the clone command:

    $ p4 clone -p perforce:1666 -r markm-remote2
    Perforce db files in '/Users/jschaffer/.p4root' will be created if missing...
    Perforce server info:
    	Server initialized and ready to use.
    Remote origin saved.
    main
    
    Changes were successfully fetched.
    Remote origin saved.
    Server jschaffer-dvcs-1422657971 saved.
  3. Next we run p4 remotes against the personal server to show that we now have a remote called "origin," which is the renamed remote we cloned from the shared server:

    $ p4 remotes
    origin perforce:1666 'Description '
  4. Next, we write the contents of the remote we passed to p4 clone to standard output to show the depot paths it specified in the DepotMap field:

    $ p4 -p perforce:1666 remote -o markm-remote2
    # A Perforce Remote Specification.
    #
    #  RemoteID:    The remote identifier.
    #  Address:     The P4PORT used by the remote server.
    #  Owner:       The user who created this remote.
    #  Options:     Remote options: [un]locked, [no]compress.
    #  Update:      The date this specification was last modified.
    #  Access:      The date of the last 'push/fetch' on this remote.
    #  Description: A short description of the remote server (optional).
    #  LastFetch:   The last changelist that was fetched.
    #  LastPush:    The last changelist that was pushed.
    #  DepotMap:    Lines to map local files to remote files.
    
    RemoteID:	markm-remote2
    
    Owner:	markm
    
    Options:	unlocked compress
    
    Update:	2014/12/11 11:15:15
    
    Description:
    	Created by markm.
    
    LastFetch:	default
    
    LastPush:	default
    
    DepotMap:
    	//depot/main/p4/msgs/... //depot/main/p4/msgs/...
  5. Finally, we write the contents of the origin remote spec to standard out to demonstrate that the depot paths it specifies in the DepotMap field are identical to those of markm-remote2:

    $ p4 remote -o origin
    # A Perforce Remote Specification.
    #
    #  RemoteID:    The remote identifier.
    #  Address:     The P4PORT used by the remote server.
    #  Owner:       The user who created this remote.
    #  Options:     Remote options: [un]locked, [no]compress.
    #  Update:      The date this specification was last modified.
    #  Access:      The date of the last 'push/fetch' on this remote.
    #  Description: A short description of the remote server (optional).
    #  LastFetch:   The last changelist that was fetched.
    #  LastPush:    The last changelist that was pushed.
    #  DepotMap:    Lines to map local files to remote files.
    
    RemoteID:	origin
    
    Address:	perforce:1666
    
    Owner:	jschaffer
    
    Options:	unlocked nocompress
    
    Update:	2015/01/30 14:46:51
    
    Description:
    	Description
    
    LastFetch:	996270
    
    LastPush:	4024
    
    DepotMap:
    	//depot/main/p4/msgs/... //depot/main/p4/msgs/...

    Notice that the LastFetch and LastPush values have changed to non-zero numbers to reflect the highest changelist numbers most recently fetched and pushed.

A closer look at a remote spec

The following is a sample remote spec, describing a remote named server-main-darwin:

# A Perforce Remote Specification.

RemoteID:       server-main-darwin

Owner:  bruno

Options:        unlocked compress

Update: 2014/11/21 08:21:32

Description:
        A fairly complete set of the mainline code for the widget, with the
        test harness limited to the darwin platform. Fetch or clone from
        this remote spec if you want to build and work with the mainline
        widget code on a darwin machine.

LastFetch:      default

LastPush:       default

DepotMap:
        //stream/main/widget/... //depot/main/widget/...
        //stream/main/widget-test/server/... //depot/main/widget-test/server/...
        //stream/main/widget-test/bin/... //depot/main/widget-test/bin/...
        -//stream/main/widget-test/bin/arch/... //depot/main/widget-test/bin/arch/...
        //stream/main/widget-test/bin/arch/darwin90x86_64/... //depot/main/widget-test/bin/arch/darwin90x86_64/...
        //stream/main/widget-doc/code/... //depot/main/widget-doc/code/...

The following table describes the remote spec in more detail:

Entry Meaning

RemoteID

The remote identifier.

Address

The P4PORT used by the remote server.

Owner

The user who created this remote.

Options ([un]locked, [no]compress)

The unlocked option setting means people other than the owner can update the spec. The compress option setting means that when files are fetched or pushed they’re compressed, as a performance optimization. You would only set this option to uncompress if you were fetching or pushing binary files that were already in a compressed format.

Update

The date this specification was last modified.

Access

The date of the last push or fetch on this remote.

Description

A short description of the remote server (optional).

LastFetch

The last changelist that was fetched. If set to default, means no fetches have yet occurred.

LastPush

The last changelist that was pushed. If set to default, means no pushes have yet occurred.

DepotMap

The lines to map local files to remote files. The file paths on the left-hand side are on the local server. The file paths on the right-hand side are on the remote server.

Remote specs give you the full power of Perforce client view syntax. For details, see the section "Defining client workspaces" in the chapter Configuring P4 in the P4 User’s Guide. Below is some basic information about creating a remote spec.