Added git-p4 clone convenience command
[fast-export.git] / git-p4.txt
blob99ae85bd7ba425a15c55ffb3db651a3698d7176d
1 git-p4 - Perforce <-> Git converter using git-fast-import
3 Usage
4 =====
6 git-p4 supports two main modes: Importing from Perforce to a Git repository is
7 done using "git-p4 sync". Submitting changes from Git back to Perforce is
8 done using "git-p4 submit".
10 Importing
11 =========
13 You can simply start with
15   git-p4 clone //depot/path/project
19   git-p4 clone //depot/path/project myproject
21 This will create an empty git repository in a subdirectory called "project" (or
22 "myproject" with the second command), import the head revision from the
23 specified perforce path into a git "p4" branch, create a master branch off it
24 and check it out. If you want the entire history (not just the head revision) then
25 you can simply append a "@all" to the depot path:
27   git-p4 clone //depot/project/main@all myproject
31 If you want more control you can also use the git-p4 sync command directly:
33   mkdir repo-git
34   cd repo-git
35   git init
36   git-p4 sync //path/in/your/perforce/depot
38 This will import the current head revision of the specified depot path into a
39 "p4" branch of your git repository. You can use the --branch=mybranch option
40 to use a different branch.
42 If you want to import the entire history of a given depot path just use
44   git-p4 sync //path/in/depot@all
46 To achieve optimal compression you may want to run 'git repack -a -d -f' after
47 a big import. This may take a while.
49 Support for Perforce integrations is still work in progress. Don't bother
50 trying it unless you want to hack on it :)
52 For convenience there's also the git-p4 clone command that works similar to
53 git-clone and combines the creation of the git repository with the the initial
54 import and the branch setup
56 Incremental Imports
57 ===================
59 After an initial import you can easily synchronize your git repository with
60 newer changes from the Perforce depot by just calling
62   git-p4 sync
64 in your git repository. By default the "p4" branch is updated.
66 It is recommended to run 'git repack -a -d -f' from time to time when using
67 incremental imports to optimally combine the individual git packs that each
68 incremental import creates through the use of git-fast-import.
70 Updating
71 ========
73 A common working pattern is to fetch the latest changes from the Perforce depot
74 and merge them with local uncommitted changes. The recommended way is to use
75 git's rebase mechanism to preserve linear history. git-p4 provides a convenient
77   git-p4 rebase
79 command that calls git-p4 sync followed by git rebase to rebase the current
80 working branch.
82 Submitting
83 ==========
85 git-p4 has support for submitting changes from a git repository back to the
86 Perforce depot. This requires a Perforce checkout separate to your git
87 repository. To submit all changes that are in the current git branch but not in
88 the "p4" branch (or "origin" if "p4" doesn't exist) simply call
90     git-p4 submit
92 in your git repository. If you want to submit changes in a specific branch that
93 is not your current git branch you can also pass that as an argument:
95     git-p4 submit mytopicbranch
97 You can override the reference branch with the --origin=mysourcebranch option.
99 If a submit fails you may have to "p4 resolve" and submit manually. You can
100 continue importing the remaining changes with
102   git-p4 submit --continue
104 After submitting you should sync your perforce import branch ("p4" or "origin")
105 from Perforce using git-p4's sync command.