1GIT-FAST-IMPORT(1)                Git Manual                GIT-FAST-IMPORT(1)
2
3
4

NAME

6       git-fast-import - Backend for fast Git data importers
7

SYNOPSIS

9       frontend | git fast-import [options]
10
11

DESCRIPTION

13       This program is usually not what the end user wants to run directly.
14       Most end users want to use one of the existing frontend programs, which
15       parses a specific type of foreign source and feeds the contents stored
16       there to git fast-import.
17
18       fast-import reads a mixed command/data stream from standard input and
19       writes one or more packfiles directly into the current repository. When
20       EOF is received on standard input, fast import writes out updated
21       branch and tag refs, fully updating the current repository with the
22       newly imported data.
23
24       The fast-import backend itself can import into an empty repository (one
25       that has already been initialized by git init) or incrementally update
26       an existing populated repository. Whether or not incremental imports
27       are supported from a particular foreign source depends on the frontend
28       program in use.
29

OPTIONS

31       --force
32           Force updating modified existing branches, even if doing so would
33           cause commits to be lost (as the new commit does not contain the
34           old commit).
35
36       --quiet
37           Disable all non-fatal output, making fast-import silent when it is
38           successful. This option disables the output shown by --stats.
39
40       --stats
41           Display some basic statistics about the objects fast-import has
42           created, the packfiles they were stored into, and the memory used
43           by fast-import during this run. Showing this output is currently
44           the default, but can be disabled with --quiet.
45
46   Options for Frontends
47       --cat-blob-fd=<fd>
48           Write responses to cat-blob and ls queries to the file descriptor
49           <fd> instead of stdout. Allows progress output intended for the
50           end-user to be separated from other output.
51
52       --date-format=<fmt>
53           Specify the type of dates the frontend will supply to fast-import
54           within author, committer and tagger commands. See “Date Formats”
55           below for details about which formats are supported, and their
56           syntax.
57
58       --done
59           Terminate with error if there is no done command at the end of the
60           stream. This option might be useful for detecting errors that cause
61           the frontend to terminate before it has started to write a stream.
62
63   Locations of Marks Files
64       --export-marks=<file>
65           Dumps the internal marks table to <file> when complete. Marks are
66           written one per line as :markid SHA-1. Frontends can use this file
67           to validate imports after they have been completed, or to save the
68           marks table across incremental runs. As <file> is only opened and
69           truncated at checkpoint (or completion) the same path can also be
70           safely given to --import-marks.
71
72       --import-marks=<file>
73           Before processing any input, load the marks specified in <file>.
74           The input file must exist, must be readable, and must use the same
75           format as produced by --export-marks. Multiple options may be
76           supplied to import more than one set of marks. If a mark is defined
77           to different values, the last file wins.
78
79       --import-marks-if-exists=<file>
80           Like --import-marks but instead of erroring out, silently skips the
81           file if it does not exist.
82
83       --[no-]relative-marks
84           After specifying --relative-marks the paths specified with
85           --import-marks= and --export-marks= are relative to an internal
86           directory in the current repository. In git-fast-import this means
87           that the paths are relative to the .git/info/fast-import directory.
88           However, other importers may use a different location.
89
90           Relative and non-relative marks may be combined by interweaving
91           --(no-)-relative-marks with the --(import|export)-marks= options.
92
93   Performance and Compression Tuning
94       --active-branches=<n>
95           Maximum number of branches to maintain active at once. See “Memory
96           Utilization” below for details. Default is 5.
97
98       --big-file-threshold=<n>
99           Maximum size of a blob that fast-import will attempt to create a
100           delta for, expressed in bytes. The default is 512m (512 MiB). Some
101           importers may wish to lower this on systems with constrained
102           memory.
103
104       --depth=<n>
105           Maximum delta depth, for blob and tree deltification. Default is
106           10.
107
108       --export-pack-edges=<file>
109           After creating a packfile, print a line of data to <file> listing
110           the filename of the packfile and the last commit on each branch
111           that was written to that packfile. This information may be useful
112           after importing projects whose total object set exceeds the 4 GiB
113           packfile limit, as these commits can be used as edge points during
114           calls to git pack-objects.
115
116       --max-pack-size=<n>
117           Maximum size of each output packfile. The default is unlimited.
118

PERFORMANCE

120       The design of fast-import allows it to import large projects in a
121       minimum amount of memory usage and processing time. Assuming the
122       frontend is able to keep up with fast-import and feed it a constant
123       stream of data, import times for projects holding 10+ years of history
124       and containing 100,000+ individual commits are generally completed in
125       just 1-2 hours on quite modest (~$2,000 USD) hardware.
126
127       Most bottlenecks appear to be in foreign source data access (the source
128       just cannot extract revisions fast enough) or disk IO (fast-import
129       writes as fast as the disk will take the data). Imports will run faster
130       if the source data is stored on a different drive than the destination
131       Git repository (due to less IO contention).
132

DEVELOPMENT COST

134       A typical frontend for fast-import tends to weigh in at approximately
135       200 lines of Perl/Python/Ruby code. Most developers have been able to
136       create working importers in just a couple of hours, even though it is
137       their first exposure to fast-import, and sometimes even to Git. This is
138       an ideal situation, given that most conversion tools are throw-away
139       (use once, and never look back).
140

PARALLEL OPERATION

142       Like git push or git fetch, imports handled by fast-import are safe to
143       run alongside parallel git repack -a -d or git gc invocations, or any
144       other Git operation (including git prune, as loose objects are never
145       used by fast-import).
146
147       fast-import does not lock the branch or tag refs it is actively
148       importing. After the import, during its ref update phase, fast-import
149       tests each existing branch ref to verify the update will be a
150       fast-forward update (the commit stored in the ref is contained in the
151       new history of the commit to be written). If the update is not a
152       fast-forward update, fast-import will skip updating that ref and
153       instead prints a warning message. fast-import will always attempt to
154       update all branch refs, and does not stop on the first failure.
155
156       Branch updates can be forced with --force, but it’s recommended that
157       this only be used on an otherwise quiet repository. Using --force is
158       not necessary for an initial import into an empty repository.
159

TECHNICAL DISCUSSION

161       fast-import tracks a set of branches in memory. Any branch can be
162       created or modified at any point during the import process by sending a
163       commit command on the input stream. This design allows a frontend
164       program to process an unlimited number of branches simultaneously,
165       generating commits in the order they are available from the source
166       data. It also simplifies the frontend programs considerably.
167
168       fast-import does not use or alter the current working directory, or any
169       file within it. (It does however update the current Git repository, as
170       referenced by GIT_DIR.) Therefore an import frontend may use the
171       working directory for its own purposes, such as extracting file
172       revisions from the foreign source. This ignorance of the working
173       directory also allows fast-import to run very quickly, as it does not
174       need to perform any costly file update operations when switching
175       between branches.
176

INPUT FORMAT

178       With the exception of raw file data (which Git does not interpret) the
179       fast-import input format is text (ASCII) based. This text based format
180       simplifies development and debugging of frontend programs, especially
181       when a higher level language such as Perl, Python or Ruby is being
182       used.
183
184       fast-import is very strict about its input. Where we say SP below we
185       mean exactly one space. Likewise LF means one (and only one) linefeed
186       and HT one (and only one) horizontal tab. Supplying additional
187       whitespace characters will cause unexpected results, such as branch
188       names or file names with leading or trailing spaces in their name, or
189       early termination of fast-import when it encounters unexpected input.
190
191   Stream Comments
192       To aid in debugging frontends fast-import ignores any line that begins
193       with # (ASCII pound/hash) up to and including the line ending LF. A
194       comment line may contain any sequence of bytes that does not contain an
195       LF and therefore may be used to include any detailed debugging
196       information that might be specific to the frontend and useful when
197       inspecting a fast-import data stream.
198
199   Date Formats
200       The following date formats are supported. A frontend should select the
201       format it will use for this import by passing the format name in the
202       --date-format=<fmt> command line option.
203
204       raw
205           This is the Git native format and is <time> SP <offutc>. It is also
206           fast-import’s default format, if --date-format was not specified.
207
208           The time of the event is specified by <time> as the number of
209           seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
210           written as an ASCII decimal integer.
211
212           The local offset is specified by <offutc> as a positive or negative
213           offset from UTC. For example EST (which is 5 hours behind UTC)
214           would be expressed in <tz> by “-0500” while UTC is “+0000”. The
215           local offset does not affect <time>; it is used only as an
216           advisement to help formatting routines display the timestamp.
217
218           If the local offset is not available in the source material, use
219           “+0000”, or the most common local offset. For example many
220           organizations have a CVS repository which has only ever been
221           accessed by users who are located in the same location and
222           timezone. In this case a reasonable offset from UTC could be
223           assumed.
224
225           Unlike the rfc2822 format, this format is very strict. Any
226           variation in formatting will cause fast-import to reject the value.
227
228       rfc2822
229           This is the standard email format as described by RFC 2822.
230
231           An example value is “Tue Feb 6 11:22:18 2007 -0500”. The Git parser
232           is accurate, but a little on the lenient side. It is the same
233           parser used by git am when applying patches received from email.
234
235           Some malformed strings may be accepted as valid dates. In some of
236           these cases Git will still be able to obtain the correct date from
237           the malformed string. There are also some types of malformed
238           strings which Git will parse wrong, and yet consider valid.
239           Seriously malformed strings will be rejected.
240
241           Unlike the raw format above, the timezone/UTC offset information
242           contained in an RFC 2822 date string is used to adjust the date
243           value to UTC prior to storage. Therefore it is important that this
244           information be as accurate as possible.
245
246           If the source material uses RFC 2822 style dates, the frontend
247           should let fast-import handle the parsing and conversion (rather
248           than attempting to do it itself) as the Git parser has been well
249           tested in the wild.
250
251           Frontends should prefer the raw format if the source material
252           already uses UNIX-epoch format, can be coaxed to give dates in that
253           format, or its format is easily convertible to it, as there is no
254           ambiguity in parsing.
255
256       now
257           Always use the current time and timezone. The literal now must
258           always be supplied for <when>.
259
260           This is a toy format. The current time and timezone of this system
261           is always copied into the identity string at the time it is being
262           created by fast-import. There is no way to specify a different time
263           or timezone.
264
265           This particular format is supplied as it’s short to implement and
266           may be useful to a process that wants to create a new commit right
267           now, without needing to use a working directory or git
268           update-index.
269
270           If separate author and committer commands are used in a commit the
271           timestamps may not match, as the system clock will be polled twice
272           (once for each command). The only way to ensure that both author
273           and committer identity information has the same timestamp is to
274           omit author (thus copying from committer) or to use a date format
275           other than now.
276
277   Commands
278       fast-import accepts several commands to update the current repository
279       and control the current import process. More detailed discussion (with
280       examples) of each command follows later.
281
282       commit
283           Creates a new branch or updates an existing branch by creating a
284           new commit and updating the branch to point at the newly created
285           commit.
286
287       tag
288           Creates an annotated tag object from an existing commit or branch.
289           Lightweight tags are not supported by this command, as they are not
290           recommended for recording meaningful points in time.
291
292       reset
293           Reset an existing branch (or a new branch) to a specific revision.
294           This command must be used to change a branch to a specific revision
295           without making a commit on it.
296
297       blob
298           Convert raw file data into a blob, for future use in a commit
299           command. This command is optional and is not needed to perform an
300           import.
301
302       checkpoint
303           Forces fast-import to close the current packfile, generate its
304           unique SHA-1 checksum and index, and start a new packfile. This
305           command is optional and is not needed to perform an import.
306
307       progress
308           Causes fast-import to echo the entire line to its own standard
309           output. This command is optional and is not needed to perform an
310           import.
311
312       done
313           Marks the end of the stream. This command is optional unless the
314           done feature was requested using the --done command line option or
315           feature done command.
316
317       cat-blob
318           Causes fast-import to print a blob in cat-file --batch format to
319           the file descriptor set with --cat-blob-fd or stdout if
320           unspecified.
321
322       ls
323           Causes fast-import to print a line describing a directory entry in
324           ls-tree format to the file descriptor set with --cat-blob-fd or
325           stdout if unspecified.
326
327       feature
328           Require that fast-import supports the specified feature, or abort
329           if it does not.
330
331       option
332           Specify any of the options listed under OPTIONS that do not change
333           stream semantic to suit the frontend’s needs. This command is
334           optional and is not needed to perform an import.
335
336   commit
337       Create or update a branch with a new commit, recording one logical
338       change to the project.
339
340                   'commit' SP <ref> LF
341                   mark?
342                   ('author' (SP <name>)? SP LT <email> GT SP <when> LF)?
343                   'committer' (SP <name>)? SP LT <email> GT SP <when> LF
344                   data
345                   ('from' SP <committish> LF)?
346                   ('merge' SP <committish> LF)?
347                   (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)*
348                   LF?
349
350       where <ref> is the name of the branch to make the commit on. Typically
351       branch names are prefixed with refs/heads/ in Git, so importing the CVS
352       branch symbol RELENG-1_0 would use refs/heads/RELENG-1_0 for the value
353       of <ref>. The value of <ref> must be a valid refname in Git. As LF is
354       not valid in a Git refname, no quoting or escaping syntax is supported
355       here.
356
357       A mark command may optionally appear, requesting fast-import to save a
358       reference to the newly created commit for future use by the frontend
359       (see below for format). It is very common for frontends to mark every
360       commit they create, thereby allowing future branch creation from any
361       imported commit.
362
363       The data command following committer must supply the commit message
364       (see below for data command syntax). To import an empty commit message
365       use a 0 length data. Commit messages are free-form and are not
366       interpreted by Git. Currently they must be encoded in UTF-8, as
367       fast-import does not permit other encodings to be specified.
368
369       Zero or more filemodify, filedelete, filecopy, filerename,
370       filedeleteall and notemodify commands may be included to update the
371       contents of the branch prior to creating the commit. These commands may
372       be supplied in any order. However it is recommended that a
373       filedeleteall command precede all filemodify, filecopy, filerename and
374       notemodify commands in the same commit, as filedeleteall wipes the
375       branch clean (see below).
376
377       The LF after the command is optional (it used to be required).
378
379       author
380           An author command may optionally appear, if the author information
381           might differ from the committer information. If author is omitted
382           then fast-import will automatically use the committer’s information
383           for the author portion of the commit. See below for a description
384           of the fields in author, as they are identical to committer.
385
386       committer
387           The committer command indicates who made this commit, and when they
388           made it.
389
390           Here <name> is the person’s display name (for example “Com M
391           Itter”) and <email> is the person’s email address
392           (“cm@example.com”). LT and GT are the literal less-than (\x3c) and
393           greater-than (\x3e) symbols. These are required to delimit the
394           email address from the other fields in the line. Note that <name>
395           and <email> are free-form and may contain any sequence of bytes,
396           except LT, GT and LF. <name> is typically UTF-8 encoded.
397
398           The time of the change is specified by <when> using the date format
399           that was selected by the --date-format=<fmt> command line option.
400           See “Date Formats” above for the set of supported formats, and
401           their syntax.
402
403       from
404           The from command is used to specify the commit to initialize this
405           branch from. This revision will be the first ancestor of the new
406           commit. The state of the tree built at this commit will begin with
407           the state at the from commit, and be altered by the content
408           modifications in this commit.
409
410           Omitting the from command in the first commit of a new branch will
411           cause fast-import to create that commit with no ancestor. This
412           tends to be desired only for the initial commit of a project. If
413           the frontend creates all files from scratch when making a new
414           branch, a merge command may be used instead of from to start the
415           commit with an empty tree. Omitting the from command on existing
416           branches is usually desired, as the current commit on that branch
417           is automatically assumed to be the first ancestor of the new
418           commit.
419
420           As LF is not valid in a Git refname or SHA-1 expression, no quoting
421           or escaping syntax is supported within <committish>.
422
423           Here <committish> is any of the following:
424
425           ·   The name of an existing branch already in fast-import’s
426               internal branch table. If fast-import doesn’t know the name,
427               it’s treated as a SHA-1 expression.
428
429           ·   A mark reference, :<idnum>, where <idnum> is the mark number.
430
431               The reason fast-import uses : to denote a mark reference is
432               this character is not legal in a Git branch name. The leading :
433               makes it easy to distinguish between the mark 42 (:42) and the
434               branch 42 (42 or refs/heads/42), or an abbreviated SHA-1 which
435               happened to consist only of base-10 digits.
436
437               Marks must be declared (via mark) before they can be used.
438
439           ·   A complete 40 byte or abbreviated commit SHA-1 in hex.
440
441           ·   Any valid Git SHA-1 expression that resolves to a commit. See
442               “SPECIFYING REVISIONS” in gitrevisions(7) for details.
443
444           The special case of restarting an incremental import from the
445           current branch value should be written as:
446
447                       from refs/heads/branch^0
448
449
450           The ^0 suffix is necessary as fast-import does not permit a branch
451           to start from itself, and the branch is created in memory before
452           the from command is even read from the input. Adding ^0 will force
453           fast-import to resolve the commit through Git’s revision parsing
454           library, rather than its internal branch table, thereby loading in
455           the existing value of the branch.
456
457       merge
458           Includes one additional ancestor commit. The additional ancestry
459           link does not change the way the tree state is built at this
460           commit. If the from command is omitted when creating a new branch,
461           the first merge commit will be the first ancestor of the current
462           commit, and the branch will start out with no files. An unlimited
463           number of merge commands per commit are permitted by fast-import,
464           thereby establishing an n-way merge. However Git’s other tools
465           never create commits with more than 15 additional ancestors
466           (forming a 16-way merge). For this reason it is suggested that
467           frontends do not use more than 15 merge commands per commit; 16, if
468           starting a new, empty branch.
469
470           Here <committish> is any of the commit specification expressions
471           also accepted by from (see above).
472
473       filemodify
474           Included in a commit command to add a new file or change the
475           content of an existing file. This command has two different means
476           of specifying the content of the file.
477
478           External data format
479               The data content for the file was already supplied by a prior
480               blob command. The frontend just needs to connect it.
481
482                           'M' SP <mode> SP <dataref> SP <path> LF
483
484               Here usually <dataref> must be either a mark reference
485               (:<idnum>) set by a prior blob command, or a full 40-byte SHA-1
486               of an existing Git blob object. If <mode> is 040000` then
487               <dataref> must be the full 40-byte SHA-1 of an existing Git
488               tree object or a mark reference set with --import-marks.
489
490           Inline data format
491               The data content for the file has not been supplied yet. The
492               frontend wants to supply it as part of this modify command.
493
494                           'M' SP <mode> SP 'inline' SP <path> LF
495                           data
496
497               See below for a detailed description of the data command.
498
499           In both formats <mode> is the type of file entry, specified in
500           octal. Git only supports the following modes:
501
502           ·   100644 or 644: A normal (not-executable) file. The majority of
503               files in most projects use this mode. If in doubt, this is what
504               you want.
505
506           ·   100755 or 755: A normal, but executable, file.
507
508           ·   120000: A symlink, the content of the file will be the link
509               target.
510
511           ·   160000: A gitlink, SHA-1 of the object refers to a commit in
512               another repository. Git links can only be specified by SHA or
513               through a commit mark. They are used to implement submodules.
514
515           ·   040000: A subdirectory. Subdirectories can only be specified by
516               SHA or through a tree mark set with --import-marks.
517
518           In both formats <path> is the complete path of the file to be added
519           (if not already existing) or modified (if already existing).
520
521           A <path> string must use UNIX-style directory separators (forward
522           slash /), may contain any byte other than LF, and must not start
523           with double quote (").
524
525           A path can use C-style string quoting; this is accepted in all
526           cases and mandatory if the filename starts with double quote or
527           contains LF. In C-style quoting, the complete name should be
528           surrounded with double quotes, and any LF, backslash, or double
529           quote characters must be escaped by preceding them with a backslash
530           (e.g., "path/with\n, \\ and \" in it").
531
532           The value of <path> must be in canonical form. That is it must not:
533
534           ·   contain an empty directory component (e.g.  foo//bar is
535               invalid),
536
537           ·   end with a directory separator (e.g.  foo/ is invalid),
538
539           ·   start with a directory separator (e.g.  /foo is invalid),
540
541           ·   contain the special component .  or ..  (e.g.  foo/./bar and
542               foo/../bar are invalid).
543
544           The root of the tree can be represented by an empty string as
545           <path>.
546
547           It is recommended that <path> always be encoded using UTF-8.
548
549       filedelete
550           Included in a commit command to remove a file or recursively delete
551           an entire directory from the branch. If the file or directory
552           removal makes its parent directory empty, the parent directory will
553           be automatically removed too. This cascades up the tree until the
554           first non-empty directory or the root is reached.
555
556                       'D' SP <path> LF
557
558           here <path> is the complete path of the file or subdirectory to be
559           removed from the branch. See filemodify above for a detailed
560           description of <path>.
561
562       filecopy
563           Recursively copies an existing file or subdirectory to a different
564           location within the branch. The existing file or directory must
565           exist. If the destination exists it will be completely replaced by
566           the content copied from the source.
567
568                       'C' SP <path> SP <path> LF
569
570           here the first <path> is the source location and the second <path>
571           is the destination. See filemodify above for a detailed description
572           of what <path> may look like. To use a source path that contains SP
573           the path must be quoted.
574
575           A filecopy command takes effect immediately. Once the source
576           location has been copied to the destination any future commands
577           applied to the source location will not impact the destination of
578           the copy.
579
580       filerename
581           Renames an existing file or subdirectory to a different location
582           within the branch. The existing file or directory must exist. If
583           the destination exists it will be replaced by the source directory.
584
585                       'R' SP <path> SP <path> LF
586
587           here the first <path> is the source location and the second <path>
588           is the destination. See filemodify above for a detailed description
589           of what <path> may look like. To use a source path that contains SP
590           the path must be quoted.
591
592           A filerename command takes effect immediately. Once the source
593           location has been renamed to the destination any future commands
594           applied to the source location will create new files there and not
595           impact the destination of the rename.
596
597           Note that a filerename is the same as a filecopy followed by a
598           filedelete of the source location. There is a slight performance
599           advantage to using filerename, but the advantage is so small that
600           it is never worth trying to convert a delete/add pair in source
601           material into a rename for fast-import. This filerename command is
602           provided just to simplify frontends that already have rename
603           information and don’t want bother with decomposing it into a
604           filecopy followed by a filedelete.
605
606       filedeleteall
607           Included in a commit command to remove all files (and also all
608           directories) from the branch. This command resets the internal
609           branch structure to have no files in it, allowing the frontend to
610           subsequently add all interesting files from scratch.
611
612                       'deleteall' LF
613
614           This command is extremely useful if the frontend does not know (or
615           does not care to know) what files are currently on the branch, and
616           therefore cannot generate the proper filedelete commands to update
617           the content.
618
619           Issuing a filedeleteall followed by the needed filemodify commands
620           to set the correct content will produce the same results as sending
621           only the needed filemodify and filedelete commands. The
622           filedeleteall approach may however require fast-import to use
623           slightly more memory per active branch (less than 1 MiB for even
624           most large projects); so frontends that can easily obtain only the
625           affected paths for a commit are encouraged to do so.
626
627       notemodify
628           Included in a commit <notes_ref> command to add a new note
629           annotating a <committish> or change this annotation contents.
630           Internally it is similar to filemodify 100644 on <committish> path
631           (maybe split into subdirectories). It’s not advised to use any
632           other commands to write to the <notes_ref> tree except
633           filedeleteall to delete all existing notes in this tree. This
634           command has two different means of specifying the content of the
635           note.
636
637           External data format
638               The data content for the note was already supplied by a prior
639               blob command. The frontend just needs to connect it to the
640               commit that is to be annotated.
641
642                           'N' SP <dataref> SP <committish> LF
643
644               Here <dataref> can be either a mark reference (:<idnum>) set by
645               a prior blob command, or a full 40-byte SHA-1 of an existing
646               Git blob object.
647
648           Inline data format
649               The data content for the note has not been supplied yet. The
650               frontend wants to supply it as part of this modify command.
651
652                           'N' SP 'inline' SP <committish> LF
653                           data
654
655               See below for a detailed description of the data command.
656
657           In both formats <committish> is any of the commit specification
658           expressions also accepted by from (see above).
659
660   mark
661       Arranges for fast-import to save a reference to the current object,
662       allowing the frontend to recall this object at a future point in time,
663       without knowing its SHA-1. Here the current object is the object
664       creation command the mark command appears within. This can be commit,
665       tag, and blob, but commit is the most common usage.
666
667                   'mark' SP ':' <idnum> LF
668
669       where <idnum> is the number assigned by the frontend to this mark. The
670       value of <idnum> is expressed as an ASCII decimal integer. The value 0
671       is reserved and cannot be used as a mark. Only values greater than or
672       equal to 1 may be used as marks.
673
674       New marks are created automatically. Existing marks can be moved to
675       another object simply by reusing the same <idnum> in another mark
676       command.
677
678   tag
679       Creates an annotated tag referring to a specific commit. To create
680       lightweight (non-annotated) tags see the reset command below.
681
682                   'tag' SP <name> LF
683                   'from' SP <committish> LF
684                   'tagger' (SP <name>)? SP LT <email> GT SP <when> LF
685                   data
686
687       where <name> is the name of the tag to create.
688
689       Tag names are automatically prefixed with refs/tags/ when stored in
690       Git, so importing the CVS branch symbol RELENG-1_0-FINAL would use just
691       RELENG-1_0-FINAL for <name>, and fast-import will write the
692       corresponding ref as refs/tags/RELENG-1_0-FINAL.
693
694       The value of <name> must be a valid refname in Git and therefore may
695       contain forward slashes. As LF is not valid in a Git refname, no
696       quoting or escaping syntax is supported here.
697
698       The from command is the same as in the commit command; see above for
699       details.
700
701       The tagger command uses the same format as committer within commit;
702       again see above for details.
703
704       The data command following tagger must supply the annotated tag message
705       (see below for data command syntax). To import an empty tag message use
706       a 0 length data. Tag messages are free-form and are not interpreted by
707       Git. Currently they must be encoded in UTF-8, as fast-import does not
708       permit other encodings to be specified.
709
710       Signing annotated tags during import from within fast-import is not
711       supported. Trying to include your own PGP/GPG signature is not
712       recommended, as the frontend does not (easily) have access to the
713       complete set of bytes which normally goes into such a signature. If
714       signing is required, create lightweight tags from within fast-import
715       with reset, then create the annotated versions of those tags offline
716       with the standard git tag process.
717
718   reset
719       Creates (or recreates) the named branch, optionally starting from a
720       specific revision. The reset command allows a frontend to issue a new
721       from command for an existing branch, or to create a new branch from an
722       existing commit without creating a new commit.
723
724                   'reset' SP <ref> LF
725                   ('from' SP <committish> LF)?
726                   LF?
727
728       For a detailed description of <ref> and <committish> see above under
729       commit and from.
730
731       The LF after the command is optional (it used to be required).
732
733       The reset command can also be used to create lightweight
734       (non-annotated) tags. For example:
735
736           reset refs/tags/938
737           from :938
738
739       would create the lightweight tag refs/tags/938 referring to whatever
740       commit mark :938 references.
741
742   blob
743       Requests writing one file revision to the packfile. The revision is not
744       connected to any commit; this connection must be formed in a subsequent
745       commit command by referencing the blob through an assigned mark.
746
747                   'blob' LF
748                   mark?
749                   data
750
751       The mark command is optional here as some frontends have chosen to
752       generate the Git SHA-1 for the blob on their own, and feed that
753       directly to commit. This is typically more work than it’s worth
754       however, as marks are inexpensive to store and easy to use.
755
756   data
757       Supplies raw data (for use as blob/file content, commit messages, or
758       annotated tag messages) to fast-import. Data can be supplied using an
759       exact byte count or delimited with a terminating line. Real frontends
760       intended for production-quality conversions should always use the exact
761       byte count format, as it is more robust and performs better. The
762       delimited format is intended primarily for testing fast-import.
763
764       Comment lines appearing within the <raw> part of data commands are
765       always taken to be part of the body of the data and are therefore never
766       ignored by fast-import. This makes it safe to import any file/message
767       content whose lines might start with #.
768
769       Exact byte count format
770           The frontend must specify the number of bytes of data.
771
772                       'data' SP <count> LF
773                       <raw> LF?
774
775           where <count> is the exact number of bytes appearing within <raw>.
776           The value of <count> is expressed as an ASCII decimal integer. The
777           LF on either side of <raw> is not included in <count> and will not
778           be included in the imported data.
779
780           The LF after <raw> is optional (it used to be required) but
781           recommended. Always including it makes debugging a fast-import
782           stream easier as the next command always starts in column 0 of the
783           next line, even if <raw> did not end with an LF.
784
785       Delimited format
786           A delimiter string is used to mark the end of the data. fast-import
787           will compute the length by searching for the delimiter. This format
788           is primarily useful for testing and is not recommended for real
789           data.
790
791                       'data' SP '<<' <delim> LF
792                       <raw> LF
793                       <delim> LF
794                       LF?
795
796           where <delim> is the chosen delimiter string. The string <delim>
797           must not appear on a line by itself within <raw>, as otherwise
798           fast-import will think the data ends earlier than it really does.
799           The LF immediately trailing <raw> is part of <raw>. This is one of
800           the limitations of the delimited format, it is impossible to supply
801           a data chunk which does not have an LF as its last byte.
802
803           The LF after <delim> LF is optional (it used to be required).
804
805   checkpoint
806       Forces fast-import to close the current packfile, start a new one, and
807       to save out all current branch refs, tags and marks.
808
809                   'checkpoint' LF
810                   LF?
811
812       Note that fast-import automatically switches packfiles when the current
813       packfile reaches --max-pack-size, or 4 GiB, whichever limit is smaller.
814       During an automatic packfile switch fast-import does not update the
815       branch refs, tags or marks.
816
817       As a checkpoint can require a significant amount of CPU time and disk
818       IO (to compute the overall pack SHA-1 checksum, generate the
819       corresponding index file, and update the refs) it can easily take
820       several minutes for a single checkpoint command to complete.
821
822       Frontends may choose to issue checkpoints during extremely large and
823       long running imports, or when they need to allow another Git process
824       access to a branch. However given that a 30 GiB Subversion repository
825       can be loaded into Git through fast-import in about 3 hours, explicit
826       checkpointing may not be necessary.
827
828       The LF after the command is optional (it used to be required).
829
830   progress
831       Causes fast-import to print the entire progress line unmodified to its
832       standard output channel (file descriptor 1) when the command is
833       processed from the input stream. The command otherwise has no impact on
834       the current import, or on any of fast-import’s internal state.
835
836                   'progress' SP <any> LF
837                   LF?
838
839       The <any> part of the command may contain any sequence of bytes that
840       does not contain LF. The LF after the command is optional. Callers may
841       wish to process the output through a tool such as sed to remove the
842       leading part of the line, for example:
843
844           frontend | git fast-import | sed 's/^progress //'
845
846       Placing a progress command immediately after a checkpoint will inform
847       the reader when the checkpoint has been completed and it can safely
848       access the refs that fast-import updated.
849
850   cat-blob
851       Causes fast-import to print a blob to a file descriptor previously
852       arranged with the --cat-blob-fd argument. The command otherwise has no
853       impact on the current import; its main purpose is to retrieve blobs
854       that may be in fast-import’s memory but not accessible from the target
855       repository.
856
857                   'cat-blob' SP <dataref> LF
858
859       The <dataref> can be either a mark reference (:<idnum>) set previously
860       or a full 40-byte SHA-1 of a Git blob, preexisting or ready to be
861       written.
862
863       Output uses the same format as git cat-file --batch:
864
865           <sha1> SP 'blob' SP <size> LF
866           <contents> LF
867
868       This command can be used anywhere in the stream that comments are
869       accepted. In particular, the cat-blob command can be used in the middle
870       of a commit but not in the middle of a data command.
871
872       See “Responses To Commands” below for details about how to read this
873       output safely.
874
875   ls
876       Prints information about the object at a path to a file descriptor
877       previously arranged with the --cat-blob-fd argument. This allows
878       printing a blob from the active commit (with cat-blob) or copying a
879       blob or tree from a previous commit for use in the current one (with
880       filemodify).
881
882       The ls command can be used anywhere in the stream that comments are
883       accepted, including the middle of a commit.
884
885       Reading from the active commit
886           This form can only be used in the middle of a commit. The path
887           names a directory entry within fast-import’s active commit. The
888           path must be quoted in this case.
889
890                       'ls' SP <path> LF
891
892       Reading from a named tree
893           The <dataref> can be a mark reference (:<idnum>) or the full
894           40-byte SHA-1 of a Git tag, commit, or tree object, preexisting or
895           waiting to be written. The path is relative to the top level of the
896           tree named by <dataref>.
897
898                       'ls' SP <dataref> SP <path> LF
899
900       See filemodify above for a detailed description of <path>.
901
902       Output uses the same format as git ls-tree <tree> -- <path>:
903
904           <mode> SP ('blob' | 'tree' | 'commit') SP <dataref> HT <path> LF
905
906       The <dataref> represents the blob, tree, or commit object at <path> and
907       can be used in later cat-blob, filemodify, or ls commands.
908
909       If there is no file or subtree at that path, git fast-import will
910       instead report
911
912           missing SP <path> LF
913
914       See “Responses To Commands” below for details about how to read this
915       output safely.
916
917   feature
918       Require that fast-import supports the specified feature, or abort if it
919       does not.
920
921                   'feature' SP <feature> ('=' <argument>)? LF
922
923       The <feature> part of the command may be any one of the following:
924
925       date-format, export-marks, relative-marks, no-relative-marks, force
926           Act as though the corresponding command-line option with a leading
927           -- was passed on the command line (see OPTIONS, above).
928
929       import-marks, import-marks-if-exists
930           Like --import-marks except in two respects: first, only one
931           "feature import-marks" or "feature import-marks-if-exists" command
932           is allowed per stream; second, an --import-marks= or
933           --import-marks-if-exists command-line option overrides any of these
934           "feature" commands in the stream; third, "feature
935           import-marks-if-exists" like a corresponding command-line option
936           silently skips a nonexistent file.
937
938       cat-blob, ls
939           Require that the backend support the cat-blob or ls command.
940           Versions of fast-import not supporting the specified command will
941           exit with a message indicating so. This lets the import error out
942           early with a clear message, rather than wasting time on the early
943           part of an import before the unsupported command is detected.
944
945       notes
946           Require that the backend support the notemodify (N) subcommand to
947           the commit command. Versions of fast-import not supporting notes
948           will exit with a message indicating so.
949
950       done
951           Error out if the stream ends without a done command. Without this
952           feature, errors causing the frontend to end abruptly at a
953           convenient point in the stream can go undetected. This may occur,
954           for example, if an import front end dies in mid-operation without
955           emitting SIGTERM or SIGKILL at its subordinate git fast-import
956           instance.
957
958   option
959       Processes the specified option so that git fast-import behaves in a way
960       that suits the frontend’s needs. Note that options specified by the
961       frontend are overridden by any options the user may specify to git
962       fast-import itself.
963
964               'option' SP <option> LF
965
966       The <option> part of the command may contain any of the options listed
967       in the OPTIONS section that do not change import semantics, without the
968       leading -- and is treated in the same way.
969
970       Option commands must be the first commands on the input (not counting
971       feature commands), to give an option command after any non-option
972       command is an error.
973
974       The following commandline options change import semantics and may
975       therefore not be passed as option:
976
977       ·   date-format
978
979       ·   import-marks
980
981       ·   export-marks
982
983       ·   cat-blob-fd
984
985       ·   force
986
987   done
988       If the done feature is not in use, treated as if EOF was read. This can
989       be used to tell fast-import to finish early.
990
991       If the --done command line option or feature done command is in use,
992       the done command is mandatory and marks the end of the stream.
993

RESPONSES TO COMMANDS

995       New objects written by fast-import are not available immediately. Most
996       fast-import commands have no visible effect until the next checkpoint
997       (or completion). The frontend can send commands to fill fast-import’s
998       input pipe without worrying about how quickly they will take effect,
999       which improves performance by simplifying scheduling.
1000
1001       For some frontends, though, it is useful to be able to read back data
1002       from the current repository as it is being updated (for example when
1003       the source material describes objects in terms of patches to be applied
1004       to previously imported objects). This can be accomplished by connecting
1005       the frontend and fast-import via bidirectional pipes:
1006
1007           mkfifo fast-import-output
1008           frontend <fast-import-output |
1009           git fast-import >fast-import-output
1010
1011       A frontend set up this way can use progress, ls, and cat-blob commands
1012       to read information from the import in progress.
1013
1014       To avoid deadlock, such frontends must completely consume any pending
1015       output from progress, ls, and cat-blob before performing writes to
1016       fast-import that might block.
1017

CRASH REPORTS

1019       If fast-import is supplied invalid input it will terminate with a
1020       non-zero exit status and create a crash report in the top level of the
1021       Git repository it was importing into. Crash reports contain a snapshot
1022       of the internal fast-import state as well as the most recent commands
1023       that lead up to the crash.
1024
1025       All recent commands (including stream comments, file changes and
1026       progress commands) are shown in the command history within the crash
1027       report, but raw file data and commit messages are excluded from the
1028       crash report. This exclusion saves space within the report file and
1029       reduces the amount of buffering that fast-import must perform during
1030       execution.
1031
1032       After writing a crash report fast-import will close the current
1033       packfile and export the marks table. This allows the frontend developer
1034       to inspect the repository state and resume the import from the point
1035       where it crashed. The modified branches and tags are not updated during
1036       a crash, as the import did not complete successfully. Branch and tag
1037       information can be found in the crash report and must be applied
1038       manually if the update is needed.
1039
1040       An example crash:
1041
1042           $ cat >in <<END_OF_INPUT
1043           # my very first test commit
1044           commit refs/heads/master
1045           committer Shawn O. Pearce <spearce> 19283 -0400
1046           # who is that guy anyway?
1047           data <<EOF
1048           this is my commit
1049           EOF
1050           M 644 inline .gitignore
1051           data <<EOF
1052           .gitignore
1053           EOF
1054           M 777 inline bob
1055           END_OF_INPUT
1056
1057           $ git fast-import <in
1058           fatal: Corrupt mode: M 777 inline bob
1059           fast-import: dumping crash report to .git/fast_import_crash_8434
1060
1061           $ cat .git/fast_import_crash_8434
1062           fast-import crash report:
1063               fast-import process: 8434
1064               parent process     : 1391
1065               at Sat Sep 1 00:58:12 2007
1066
1067           fatal: Corrupt mode: M 777 inline bob
1068
1069           Most Recent Commands Before Crash
1070           ---------------------------------
1071             # my very first test commit
1072             commit refs/heads/master
1073             committer Shawn O. Pearce <spearce> 19283 -0400
1074             # who is that guy anyway?
1075             data <<EOF
1076             M 644 inline .gitignore
1077             data <<EOF
1078           * M 777 inline bob
1079
1080           Active Branch LRU
1081           -----------------
1082               active_branches = 1 cur, 5 max
1083
1084           pos  clock name
1085           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1086            1)      0 refs/heads/master
1087
1088           Inactive Branches
1089           -----------------
1090           refs/heads/master:
1091             status      : active loaded dirty
1092             tip commit  : 0000000000000000000000000000000000000000
1093             old tree    : 0000000000000000000000000000000000000000
1094             cur tree    : 0000000000000000000000000000000000000000
1095             commit clock: 0
1096             last pack   :
1097
1098           -------------------
1099           END OF CRASH REPORT
1100

TIPS AND TRICKS

1102       The following tips and tricks have been collected from various users of
1103       fast-import, and are offered here as suggestions.
1104
1105   Use One Mark Per Commit
1106       When doing a repository conversion, use a unique mark per commit (mark
1107       :<n>) and supply the --export-marks option on the command line.
1108       fast-import will dump a file which lists every mark and the Git object
1109       SHA-1 that corresponds to it. If the frontend can tie the marks back to
1110       the source repository, it is easy to verify the accuracy and
1111       completeness of the import by comparing each Git commit to the
1112       corresponding source revision.
1113
1114       Coming from a system such as Perforce or Subversion this should be
1115       quite simple, as the fast-import mark can also be the Perforce
1116       changeset number or the Subversion revision number.
1117
1118   Freely Skip Around Branches
1119       Don’t bother trying to optimize the frontend to stick to one branch at
1120       a time during an import. Although doing so might be slightly faster for
1121       fast-import, it tends to increase the complexity of the frontend code
1122       considerably.
1123
1124       The branch LRU builtin to fast-import tends to behave very well, and
1125       the cost of activating an inactive branch is so low that bouncing
1126       around between branches has virtually no impact on import performance.
1127
1128   Handling Renames
1129       When importing a renamed file or directory, simply delete the old
1130       name(s) and modify the new name(s) during the corresponding commit. Git
1131       performs rename detection after-the-fact, rather than explicitly during
1132       a commit.
1133
1134   Use Tag Fixup Branches
1135       Some other SCM systems let the user create a tag from multiple files
1136       which are not from the same commit/changeset. Or to create tags which
1137       are a subset of the files available in the repository.
1138
1139       Importing these tags as-is in Git is impossible without making at least
1140       one commit which “fixes up” the files to match the content of the tag.
1141       Use fast-import’s reset command to reset a dummy branch outside of your
1142       normal branch space to the base commit for the tag, then commit one or
1143       more file fixup commits, and finally tag the dummy branch.
1144
1145       For example since all normal branches are stored under refs/heads/ name
1146       the tag fixup branch TAG_FIXUP. This way it is impossible for the fixup
1147       branch used by the importer to have namespace conflicts with real
1148       branches imported from the source (the name TAG_FIXUP is not
1149       refs/heads/TAG_FIXUP).
1150
1151       When committing fixups, consider using merge to connect the commit(s)
1152       which are supplying file revisions to the fixup branch. Doing so will
1153       allow tools such as git blame to track through the real commit history
1154       and properly annotate the source files.
1155
1156       After fast-import terminates the frontend will need to do rm
1157       .git/TAG_FIXUP to remove the dummy branch.
1158
1159   Import Now, Repack Later
1160       As soon as fast-import completes the Git repository is completely valid
1161       and ready for use. Typically this takes only a very short time, even
1162       for considerably large projects (100,000+ commits).
1163
1164       However repacking the repository is necessary to improve data locality
1165       and access performance. It can also take hours on extremely large
1166       projects (especially if -f and a large --window parameter is used).
1167       Since repacking is safe to run alongside readers and writers, run the
1168       repack in the background and let it finish when it finishes. There is
1169       no reason to wait to explore your new Git project!
1170
1171       If you choose to wait for the repack, don’t try to run benchmarks or
1172       performance tests until repacking is completed. fast-import outputs
1173       suboptimal packfiles that are simply never seen in real use situations.
1174
1175   Repacking Historical Data
1176       If you are repacking very old imported data (e.g. older than the last
1177       year), consider expending some extra CPU time and supplying --window=50
1178       (or higher) when you run git repack. This will take longer, but will
1179       also produce a smaller packfile. You only need to expend the effort
1180       once, and everyone using your project will benefit from the smaller
1181       repository.
1182
1183   Include Some Progress Messages
1184       Every once in a while have your frontend emit a progress message to
1185       fast-import. The contents of the messages are entirely free-form, so
1186       one suggestion would be to output the current month and year each time
1187       the current commit date moves into the next month. Your users will feel
1188       better knowing how much of the data stream has been processed.
1189

PACKFILE OPTIMIZATION

1191       When packing a blob fast-import always attempts to deltify against the
1192       last blob written. Unless specifically arranged for by the frontend,
1193       this will probably not be a prior version of the same file, so the
1194       generated delta will not be the smallest possible. The resulting
1195       packfile will be compressed, but will not be optimal.
1196
1197       Frontends which have efficient access to all revisions of a single file
1198       (for example reading an RCS/CVS ,v file) can choose to supply all
1199       revisions of that file as a sequence of consecutive blob commands. This
1200       allows fast-import to deltify the different file revisions against each
1201       other, saving space in the final packfile. Marks can be used to later
1202       identify individual file revisions during a sequence of commit
1203       commands.
1204
1205       The packfile(s) created by fast-import do not encourage good disk
1206       access patterns. This is caused by fast-import writing the data in the
1207       order it is received on standard input, while Git typically organizes
1208       data within packfiles to make the most recent (current tip) data appear
1209       before historical data. Git also clusters commits together, speeding up
1210       revision traversal through better cache locality.
1211
1212       For this reason it is strongly recommended that users repack the
1213       repository with git repack -a -d after fast-import completes, allowing
1214       Git to reorganize the packfiles for faster data access. If blob deltas
1215       are suboptimal (see above) then also adding the -f option to force
1216       recomputation of all deltas can significantly reduce the final packfile
1217       size (30-50% smaller can be quite typical).
1218

MEMORY UTILIZATION

1220       There are a number of factors which affect how much memory fast-import
1221       requires to perform an import. Like critical sections of core Git,
1222       fast-import uses its own memory allocators to amortize any overheads
1223       associated with malloc. In practice fast-import tends to amortize any
1224       malloc overheads to 0, due to its use of large block allocations.
1225
1226   per object
1227       fast-import maintains an in-memory structure for every object written
1228       in this execution. On a 32 bit system the structure is 32 bytes, on a
1229       64 bit system the structure is 40 bytes (due to the larger pointer
1230       sizes). Objects in the table are not deallocated until fast-import
1231       terminates. Importing 2 million objects on a 32 bit system will require
1232       approximately 64 MiB of memory.
1233
1234       The object table is actually a hashtable keyed on the object name (the
1235       unique SHA-1). This storage configuration allows fast-import to reuse
1236       an existing or already written object and avoid writing duplicates to
1237       the output packfile. Duplicate blobs are surprisingly common in an
1238       import, typically due to branch merges in the source.
1239
1240   per mark
1241       Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
1242       bytes, depending on pointer size) per mark. Although the array is
1243       sparse, frontends are still strongly encouraged to use marks between 1
1244       and n, where n is the total number of marks required for this import.
1245
1246   per branch
1247       Branches are classified as active and inactive. The memory usage of the
1248       two classes is significantly different.
1249
1250       Inactive branches are stored in a structure which uses 96 or 120 bytes
1251       (32 bit or 64 bit systems, respectively), plus the length of the branch
1252       name (typically under 200 bytes), per branch. fast-import will easily
1253       handle as many as 10,000 inactive branches in under 2 MiB of memory.
1254
1255       Active branches have the same overhead as inactive branches, but also
1256       contain copies of every tree that has been recently modified on that
1257       branch. If subtree include has not been modified since the branch
1258       became active, its contents will not be loaded into memory, but if
1259       subtree src has been modified by a commit since the branch became
1260       active, then its contents will be loaded in memory.
1261
1262       As active branches store metadata about the files contained on that
1263       branch, their in-memory storage size can grow to a considerable size
1264       (see below).
1265
1266       fast-import automatically moves active branches to inactive status
1267       based on a simple least-recently-used algorithm. The LRU chain is
1268       updated on each commit command. The maximum number of active branches
1269       can be increased or decreased on the command line with
1270       --active-branches=.
1271
1272   per active tree
1273       Trees (aka directories) use just 12 bytes of memory on top of the
1274       memory required for their entries (see “per active file” below). The
1275       cost of a tree is virtually 0, as its overhead amortizes out over the
1276       individual file entries.
1277
1278   per active file entry
1279       Files (and pointers to subtrees) within active trees require 52 or 64
1280       bytes (32/64 bit platforms) per entry. To conserve space, file and tree
1281       names are pooled in a common string table, allowing the filename
1282       “Makefile” to use just 16 bytes (after including the string header
1283       overhead) no matter how many times it occurs within the project.
1284
1285       The active branch LRU, when coupled with the filename string pool and
1286       lazy loading of subtrees, allows fast-import to efficiently import
1287       projects with 2,000+ branches and 45,114+ files in a very limited
1288       memory footprint (less than 2.7 MiB per active branch).
1289

SIGNALS

1291       Sending SIGUSR1 to the git fast-import process ends the current
1292       packfile early, simulating a checkpoint command. The impatient operator
1293       can use this facility to peek at the objects and refs from an import in
1294       progress, at the cost of some added running time and worse compression.
1295

GIT

1297       Part of the git(1) suite
1298
1299
1300
1301Git 1.8.3.1                       11/19/2018                GIT-FAST-IMPORT(1)
Impressum