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 than the current one, use:
------------
$ git p4 submit topicbranch
------------
To specify a single commit or a range of commits, use:
------------
$ git p4 submit --commit <sha1>
$ git p4 submit --commit <sha1..sha1>
------------
The upstream reference is generally 'refs/remotes/p4/master', but can
be overridden using the `--origin=` command-line option.
The p4 changes will be created as the user invoking 'git p4 submit'. The
`--preserve-user` option will cause ownership to be modified
according to the author of the Git commit. This option requires admin
privileges in p4, which can be granted using 'p4 protect'.
To shelve changes instead of submitting, use `--shelve` and `--update-shelve`:
----
$ git p4 submit --shelve
$ git p4 submit --update-shelve 1234 --update-shelve 2345
----
Unshelve
~~~~~~~~
Unshelving will take a shelved P4 changelist, and produce the equivalent git commit
in the branch refs/remotes/p4-unshelved/<changelist>.
The git commit is created relative to the current origin revision (HEAD by default).
A parent commit is created based on the origin, and then the unshelve commit is
created based on that.
The origin revision can be changed with the "--origin" option.
If the target branch in refs/remotes/p4-unshelved already exists, the old one will
be renamed.
----
$ git p4 sync
$ git p4 unshelve 12345
$ git show p4-unshelved/12345
<submit more changes via p4 to the same files>
$ git p4 unshelve 12345
<refuses to unshelve until git is in sync with p4 again>
----
OPTIONS
-------
General options
~~~~~~~~~~~~~~~
All commands except clone accept these options.
--git-dir <dir>::
Set the `GIT_DIR` environment variable. See linkgit:git[1].
-v::
--verbose::
Provide more progress information.
Sync options
~~~~~~~~~~~~
These options can be used in the initial 'clone' as well as in
subsequent 'sync' operations.
--branch <ref>::
Import changes into <ref> instead of refs/remotes/p4/master.
If <ref> starts with refs/, it is used as is. Otherwise, if
it does not start with p4/, that prefix is added.
+
By default a <ref> not starting with refs/ is treated as the
name of a remote-tracking branch (under refs/remotes/). This
behavior can be modified using the --import-local option.
+
The default <ref> is "master".
+
This example imports a new remote "p4/proj2" into an existing
Git repository:
+
----
$ git init
$ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2
----
--detect-branches::
Use the branch detection algorithm to find new paths in p4. It is
documented below in "BRANCH DETECTION".
--changesfile <file>::
Import exactly the p4 change numbers listed in 'file', one per
line. Normally, 'git p4' inspects the current p4 repository
state and detects the changes it should import.
--silent::
Do not print any progress information.
--detect-labels::
Query p4 for labels associated with the depot paths, and add
them as tags in Git. Limited usefulness as only imports labels
associated with new changelists.