git-p4(1)
=========
NAME
----
git-p4 - Import from and submit to Perforce repositories
SYNOPSIS
--------
[verse]
'git p4 clone' [<sync-options>] [<clone-options>] <p4-depot-path>...
'git p4 sync' [<sync-options>] [<p4-depot-path>...]
'git p4 rebase'
'git p4 submit' [<submit-options>] [<master-branch-name>]
DESCRIPTION
-----------
This command provides a way to interact with p4 repositories
using Git.
Create a new Git repository from an existing p4 repository using
'git p4 clone', giving it one or more p4 depot paths. Incorporate
new commits from p4 changes with 'git p4 sync'. The 'sync' command
is also used to include new branches from other p4 depot paths.
Submit Git changes back to p4 using 'git p4 submit'. The command
'git p4 rebase' does a sync plus rebases the current branch onto
the updated p4 remote branch.
EXAMPLES
--------
* Clone a repository:
+
------------
$ git p4 clone //depot/path/project
------------
* Do some work in the newly created Git repository:
+
------------
$ cd project
$ vi foo.h
$ git commit -a -m "edited foo.h"
------------
* Update the Git repository with recent changes from p4, rebasing your
work on top:
+
------------
$ git p4 rebase
------------
* Submit your commits back to p4:
+
------------
$ git p4 submit
------------
COMMANDS
--------
Clone
~~~~~
Generally, 'git p4 clone' is used to create a new Git directory
from an existing p4 repository:
------------
$ git p4 clone //depot/path/project
------------
This:
1. Creates an empty Git repository in a subdirectory called 'project'.
+
2. Imports the full contents of the head revision from the given p4
depot path into a single commit in the Git branch 'refs/remotes/p4/master'.
+
3. Creates a local branch, 'master' from this remote and checks it out.
To reproduce the entire p4 history in Git, use the '@all' modifier on
the depot path:
------------
$ git p4 clone //depot/path/project@all
------------
Sync
~~~~
As development continues in the p4 repository, those changes can
be included in the Git repository using:
------------
$ git p4 sync
------------
This command finds new changes in p4 and imports them as Git commits.
P4 repositories can be added to an existing Git repository using
'git p4 sync' too:
------------
$ mkdir repo-git
$ cd repo-git
$ git init
$ git p4 sync //path/in/your/perforce/depot
------------
This imports the specified depot into
'refs/remotes/p4/master' in an existing Git repository. The
`--branch` option can be used to specify a different branch to
be used for the p4 content.
If a Git repository includes branches 'refs/remotes/origin/p4', these
will be fetched and consulted first during a 'git p4 sync'. Since
importing directly from p4 is considerably slower than pulling changes
from a Git remote, this can be useful in a multi-developer environment.
If there are multiple branches, doing 'git p4 sync' will automatically
use the "BRANCH DETECTION" algorithm to try to partition new changes
into the right branch. This can be overridden with the `--branch`
option to specify just a single branch to update.
Rebase
~~~~~~
A common working pattern is to fetch the latest changes from the p4 depot
and merge them with local uncommitted changes. Often, the p4 repository
is the ultimate location for all code, thus a rebase workflow makes
sense. This command does 'git p4 sync' followed by 'git rebase' to move
local commits on top of updated p4 changes.
------------
$ git p4 rebase
------------
Submit
~~~~~~
Submitting changes from a Git repository back to the p4 repository
requires a separate p4 client workspace. This should be specified
using the `P4CLIENT` environment variable or the Git configuration
variable 'git-p4.client'. The p4 client must exist, but the client root
will be created and populated if it does not already exist.
To submit all changes that are in the current Git branch but not in
the 'p4/master' branch, use:
------------
$ git p4 submit
------------
To specify a branch other