1GIT-FAST-IMPORT(1) Git Manual GIT-FAST-IMPORT(1)
2
3
4
6 git-fast-import - Backend for fast Git data importers
7
9 frontend | git fast-import [options]
10
12 This program is usually not what the end user wants to run directly.
13 Most end users want to use one of the existing frontend programs, which
14 parses a specific type of foreign source and feeds the contents stored
15 there to git fast-import.
16
17 fast-import reads a mixed command/data stream from standard input and
18 writes one or more packfiles directly into the current repository. When
19 EOF is received on standard input, fast import writes out updated
20 branch and tag refs, fully updating the current repository with the
21 newly imported data.
22
23 The fast-import backend itself can import into an empty repository (one
24 that has already been initialized by git init) or incrementally update
25 an existing populated repository. Whether or not incremental imports
26 are supported from a particular foreign source depends on the frontend
27 program in use.
28
30 --date-format=<fmt>
31 Specify the type of dates the frontend will supply to fast-import
32 within author, committer and tagger commands. See “Date Formats”
33 below for details about which formats are supported, and their
34 syntax.
35
36 --force
37 Force updating modified existing branches, even if doing so would
38 cause commits to be lost (as the new commit does not contain the
39 old commit).
40
41 --max-pack-size=<n>
42 Maximum size of each output packfile. The default is unlimited.
43
44 --big-file-threshold=<n>
45 Maximum size of a blob that fast-import will attempt to create a
46 delta for, expressed in bytes. The default is 512m (512 MiB). Some
47 importers may wish to lower this on systems with constrained
48 memory.
49
50 --depth=<n>
51 Maximum delta depth, for blob and tree deltification. Default is
52 10.
53
54 --active-branches=<n>
55 Maximum number of branches to maintain active at once. See “Memory
56 Utilization” below for details. Default is 5.
57
58 --export-marks=<file>
59 Dumps the internal marks table to <file> when complete. Marks are
60 written one per line as :markid SHA-1. Frontends can use this file
61 to validate imports after they have been completed, or to save the
62 marks table across incremental runs. As <file> is only opened and
63 truncated at checkpoint (or completion) the same path can also be
64 safely given to --import-marks.
65
66 --import-marks=<file>
67 Before processing any input, load the marks specified in <file>.
68 The input file must exist, must be readable, and must use the same
69 format as produced by --export-marks. Multiple options may be
70 supplied to import more than one set of marks. If a mark is defined
71 to different values, the last file wins.
72
73 --relative-marks
74 After specifying --relative-marks= the paths specified with
75 --import-marks= and --export-marks= are relative to an internal
76 directory in the current repository. In git-fast-import this means
77 that the paths are relative to the .git/info/fast-import directory.
78 However, other importers may use a different location.
79
80 --no-relative-marks
81 Negates a previous --relative-marks. Allows for combining relative
82 and non-relative marks by interweaving --(no-)-relative-marks= with
83 the --(import|export)-marks= options.
84
85 --export-pack-edges=<file>
86 After creating a packfile, print a line of data to <file> listing
87 the filename of the packfile and the last commit on each branch
88 that was written to that packfile. This information may be useful
89 after importing projects whose total object set exceeds the 4 GiB
90 packfile limit, as these commits can be used as edge points during
91 calls to git pack-objects.
92
93 --quiet
94 Disable all non-fatal output, making fast-import silent when it is
95 successful. This option disables the output shown by --stats.
96
97 --stats
98 Display some basic statistics about the objects fast-import has
99 created, the packfiles they were stored into, and the memory used
100 by fast-import during this run. Showing this output is currently
101 the default, but can be disabled with --quiet.
102
104 The design of fast-import allows it to import large projects in a
105 minimum amount of memory usage and processing time. Assuming the
106 frontend is able to keep up with fast-import and feed it a constant
107 stream of data, import times for projects holding 10+ years of history
108 and containing 100,000+ individual commits are generally completed in
109 just 1-2 hours on quite modest (~$2,000 USD) hardware.
110
111 Most bottlenecks appear to be in foreign source data access (the source
112 just cannot extract revisions fast enough) or disk IO (fast-import
113 writes as fast as the disk will take the data). Imports will run faster
114 if the source data is stored on a different drive than the destination
115 Git repository (due to less IO contention).
116
118 A typical frontend for fast-import tends to weigh in at approximately
119 200 lines of Perl/Python/Ruby code. Most developers have been able to
120 create working importers in just a couple of hours, even though it is
121 their first exposure to fast-import, and sometimes even to Git. This is
122 an ideal situation, given that most conversion tools are throw-away
123 (use once, and never look back).
124
126 Like git push or git fetch, imports handled by fast-import are safe to
127 run alongside parallel git repack -a -d or git gc invocations, or any
128 other Git operation (including git prune, as loose objects are never
129 used by fast-import).
130
131 fast-import does not lock the branch or tag refs it is actively
132 importing. After the import, during its ref update phase, fast-import
133 tests each existing branch ref to verify the update will be a
134 fast-forward update (the commit stored in the ref is contained in the
135 new history of the commit to be written). If the update is not a
136 fast-forward update, fast-import will skip updating that ref and
137 instead prints a warning message. fast-import will always attempt to
138 update all branch refs, and does not stop on the first failure.
139
140 Branch updates can be forced with --force, but it’s recommended that
141 this only be used on an otherwise quiet repository. Using --force is
142 not necessary for an initial import into an empty repository.
143
145 fast-import tracks a set of branches in memory. Any branch can be
146 created or modified at any point during the import process by sending a
147 commit command on the input stream. This design allows a frontend
148 program to process an unlimited number of branches simultaneously,
149 generating commits in the order they are available from the source
150 data. It also simplifies the frontend programs considerably.
151
152 fast-import does not use or alter the current working directory, or any
153 file within it. (It does however update the current Git repository, as
154 referenced by GIT_DIR.) Therefore an import frontend may use the
155 working directory for its own purposes, such as extracting file
156 revisions from the foreign source. This ignorance of the working
157 directory also allows fast-import to run very quickly, as it does not
158 need to perform any costly file update operations when switching
159 between branches.
160
162 With the exception of raw file data (which Git does not interpret) the
163 fast-import input format is text (ASCII) based. This text based format
164 simplifies development and debugging of frontend programs, especially
165 when a higher level language such as Perl, Python or Ruby is being
166 used.
167
168 fast-import is very strict about its input. Where we say SP below we
169 mean exactly one space. Likewise LF means one (and only one) linefeed.
170 Supplying additional whitespace characters will cause unexpected
171 results, such as branch names or file names with leading or trailing
172 spaces in their name, or early termination of fast-import when it
173 encounters unexpected input.
174
175 Stream Comments
176 To aid in debugging frontends fast-import ignores any line that begins
177 with # (ASCII pound/hash) up to and including the line ending LF. A
178 comment line may contain any sequence of bytes that does not contain an
179 LF and therefore may be used to include any detailed debugging
180 information that might be specific to the frontend and useful when
181 inspecting a fast-import data stream.
182
183 Date Formats
184 The following date formats are supported. A frontend should select the
185 format it will use for this import by passing the format name in the
186 --date-format=<fmt> command line option.
187
188 raw
189 This is the Git native format and is <time> SP <offutc>. It is also
190 fast-import’s default format, if --date-format was not specified.
191
192 The time of the event is specified by <time> as the number of
193 seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
194 written as an ASCII decimal integer.
195
196 The local offset is specified by <offutc> as a positive or negative
197 offset from UTC. For example EST (which is 5 hours behind UTC)
198 would be expressed in <tz> by “-0500” while UTC is “+0000”. The
199 local offset does not affect <time>; it is used only as an
200 advisement to help formatting routines display the timestamp.
201
202 If the local offset is not available in the source material, use
203 “+0000”, or the most common local offset. For example many
204 organizations have a CVS repository which has only ever been
205 accessed by users who are located in the same location and
206 timezone. In this case a reasonable offset from UTC could be
207 assumed.
208
209 Unlike the rfc2822 format, this format is very strict. Any
210 variation in formatting will cause fast-import to reject the value.
211
212 rfc2822
213 This is the standard email format as described by RFC 2822.
214
215 An example value is “Tue Feb 6 11:22:18 2007 -0500”. The Git parser
216 is accurate, but a little on the lenient side. It is the same
217 parser used by git am when applying patches received from email.
218
219 Some malformed strings may be accepted as valid dates. In some of
220 these cases Git will still be able to obtain the correct date from
221 the malformed string. There are also some types of malformed
222 strings which Git will parse wrong, and yet consider valid.
223 Seriously malformed strings will be rejected.
224
225 Unlike the raw format above, the timezone/UTC offset information
226 contained in an RFC 2822 date string is used to adjust the date
227 value to UTC prior to storage. Therefore it is important that this
228 information be as accurate as possible.
229
230 If the source material uses RFC 2822 style dates, the frontend
231 should let fast-import handle the parsing and conversion (rather
232 than attempting to do it itself) as the Git parser has been well
233 tested in the wild.
234
235 Frontends should prefer the raw format if the source material
236 already uses UNIX-epoch format, can be coaxed to give dates in that
237 format, or its format is easily convertible to it, as there is no
238 ambiguity in parsing.
239
240 now
241 Always use the current time and timezone. The literal now must
242 always be supplied for <when>.
243
244 This is a toy format. The current time and timezone of this system
245 is always copied into the identity string at the time it is being
246 created by fast-import. There is no way to specify a different time
247 or timezone.
248
249 This particular format is supplied as it’s short to implement and
250 may be useful to a process that wants to create a new commit right
251 now, without needing to use a working directory or git
252 update-index.
253
254 If separate author and committer commands are used in a commit the
255 timestamps may not match, as the system clock will be polled twice
256 (once for each command). The only way to ensure that both author
257 and committer identity information has the same timestamp is to
258 omit author (thus copying from committer) or to use a date format
259 other than now.
260
261 Commands
262 fast-import accepts several commands to update the current repository
263 and control the current import process. More detailed discussion (with
264 examples) of each command follows later.
265
266 commit
267 Creates a new branch or updates an existing branch by creating a
268 new commit and updating the branch to point at the newly created
269 commit.
270
271 tag
272 Creates an annotated tag object from an existing commit or branch.
273 Lightweight tags are not supported by this command, as they are not
274 recommended for recording meaningful points in time.
275
276 reset
277 Reset an existing branch (or a new branch) to a specific revision.
278 This command must be used to change a branch to a specific revision
279 without making a commit on it.
280
281 blob
282 Convert raw file data into a blob, for future use in a commit
283 command. This command is optional and is not needed to perform an
284 import.
285
286 checkpoint
287 Forces fast-import to close the current packfile, generate its
288 unique SHA-1 checksum and index, and start a new packfile. This
289 command is optional and is not needed to perform an import.
290
291 progress
292 Causes fast-import to echo the entire line to its own standard
293 output. This command is optional and is not needed to perform an
294 import.
295
296 feature
297 Require that fast-import supports the specified feature, or abort
298 if it does not.
299
300 option
301 Specify any of the options listed under OPTIONS that do not change
302 stream semantic to suit the frontend’s needs. This command is
303 optional and is not needed to perform an import.
304
305 commit
306 Create or update a branch with a new commit, recording one logical
307 change to the project.
308
309 ´commit´ SP <ref> LF
310 mark?
311 (´author´ (SP <name>)? SP LT <email> GT SP <when> LF)?
312 ´committer´ (SP <name>)? SP LT <email> GT SP <when> LF
313 data
314 (´from´ SP <committish> LF)?
315 (´merge´ SP <committish> LF)?
316 (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)*
317 LF?
318
319 where <ref> is the name of the branch to make the commit on. Typically
320 branch names are prefixed with refs/heads/ in Git, so importing the CVS
321 branch symbol RELENG-1_0 would use refs/heads/RELENG-1_0 for the value
322 of <ref>. The value of <ref> must be a valid refname in Git. As LF is
323 not valid in a Git refname, no quoting or escaping syntax is supported
324 here.
325
326 A mark command may optionally appear, requesting fast-import to save a
327 reference to the newly created commit for future use by the frontend
328 (see below for format). It is very common for frontends to mark every
329 commit they create, thereby allowing future branch creation from any
330 imported commit.
331
332 The data command following committer must supply the commit message
333 (see below for data command syntax). To import an empty commit message
334 use a 0 length data. Commit messages are free-form and are not
335 interpreted by Git. Currently they must be encoded in UTF-8, as
336 fast-import does not permit other encodings to be specified.
337
338 Zero or more filemodify, filedelete, filecopy, filerename,
339 filedeleteall and notemodify commands may be included to update the
340 contents of the branch prior to creating the commit. These commands may
341 be supplied in any order. However it is recommended that a
342 filedeleteall command precede all filemodify, filecopy, filerename and
343 notemodify commands in the same commit, as filedeleteall wipes the
344 branch clean (see below).
345
346 The LF after the command is optional (it used to be required).
347
348 author
349 An author command may optionally appear, if the author information
350 might differ from the committer information. If author is omitted
351 then fast-import will automatically use the committer’s information
352 for the author portion of the commit. See below for a description
353 of the fields in author, as they are identical to committer.
354
355 committer
356 The committer command indicates who made this commit, and when they
357 made it.
358
359 Here <name> is the person’s display name (for example “Com M
360 Itter”) and <email> is the person’s email address
361 (“cm@example.com[1]”). LT and GT are the literal less-than (\x3c)
362 and greater-than (\x3e) symbols. These are required to delimit the
363 email address from the other fields in the line. Note that <name>
364 is free-form and may contain any sequence of bytes, except LT and
365 LF. It is typically UTF-8 encoded.
366
367 The time of the change is specified by <when> using the date format
368 that was selected by the --date-format=<fmt> command line option.
369 See “Date Formats” above for the set of supported formats, and
370 their syntax.
371
372 from
373 The from command is used to specify the commit to initialize this
374 branch from. This revision will be the first ancestor of the new
375 commit.
376
377 Omitting the from command in the first commit of a new branch will
378 cause fast-import to create that commit with no ancestor. This
379 tends to be desired only for the initial commit of a project. If
380 the frontend creates all files from scratch when making a new
381 branch, a merge command may be used instead of from to start the
382 commit with an empty tree. Omitting the from command on existing
383 branches is usually desired, as the current commit on that branch
384 is automatically assumed to be the first ancestor of the new
385 commit.
386
387 As LF is not valid in a Git refname or SHA-1 expression, no quoting
388 or escaping syntax is supported within <committish>.
389
390 Here <committish> is any of the following:
391
392 · The name of an existing branch already in fast-import’s
393 internal branch table. If fast-import doesn’t know the name,
394 it’s treated as a SHA-1 expression.
395
396 · A mark reference, :<idnum>, where <idnum> is the mark number.
397
398 The reason fast-import uses : to denote a mark reference is
399 this character is not legal in a Git branch name. The leading :
400 makes it easy to distinguish between the mark 42 (:42) and the
401 branch 42 (42 or refs/heads/42), or an abbreviated SHA-1 which
402 happened to consist only of base-10 digits.
403
404 Marks must be declared (via mark) before they can be used.
405
406 · A complete 40 byte or abbreviated commit SHA-1 in hex.
407
408 · Any valid Git SHA-1 expression that resolves to a commit. See
409 “SPECIFYING REVISIONS” in git-rev-parse(1) for details.
410
411 The special case of restarting an incremental import from the
412 current branch value should be written as:
413
414 from refs/heads/branch^0
415
416
417 The ^0 suffix is necessary as fast-import does not permit a branch
418 to start from itself, and the branch is created in memory before
419 the from command is even read from the input. Adding ^0 will force
420 fast-import to resolve the commit through Git’s revision parsing
421 library, rather than its internal branch table, thereby loading in
422 the existing value of the branch.
423
424 merge
425 Includes one additional ancestor commit. If the from command is
426 omitted when creating a new branch, the first merge commit will be
427 the first ancestor of the current commit, and the branch will start
428 out with no files. An unlimited number of merge commands per commit
429 are permitted by fast-import, thereby establishing an n-way merge.
430 However Git’s other tools never create commits with more than 15
431 additional ancestors (forming a 16-way merge). For this reason it
432 is suggested that frontends do not use more than 15 merge commands
433 per commit; 16, if starting a new, empty branch.
434
435 Here <committish> is any of the commit specification expressions
436 also accepted by from (see above).
437
438 filemodify
439 Included in a commit command to add a new file or change the
440 content of an existing file. This command has two different means
441 of specifying the content of the file.
442
443 External data format
444 The data content for the file was already supplied by a prior
445 blob command. The frontend just needs to connect it.
446
447 ´M´ SP <mode> SP <dataref> SP <path> LF
448
449 Here <dataref> can be either a mark reference (:<idnum>) set by
450 a prior blob command, or a full 40-byte SHA-1 of an existing
451 Git blob object.
452
453 Inline data format
454 The data content for the file has not been supplied yet. The
455 frontend wants to supply it as part of this modify command.
456
457 ´M´ SP <mode> SP ´inline´ SP <path> LF
458 data
459
460 See below for a detailed description of the data command.
461
462 In both formats <mode> is the type of file entry, specified in
463 octal. Git only supports the following modes:
464
465 · 100644 or 644: A normal (not-executable) file. The majority of
466 files in most projects use this mode. If in doubt, this is what
467 you want.
468
469 · 100755 or 755: A normal, but executable, file.
470
471 · 120000: A symlink, the content of the file will be the link
472 target.
473
474 · 160000: A gitlink, SHA-1 of the object refers to a commit in
475 another repository. Git links can only be specified by SHA or
476 through a commit mark. They are used to implement submodules.
477
478 In both formats <path> is the complete path of the file to be added
479 (if not already existing) or modified (if already existing).
480
481 A <path> string must use UNIX-style directory separators (forward
482 slash /), may contain any byte other than LF, and must not start
483 with double quote (").
484
485 If an LF or double quote must be encoded into <path> shell-style
486 quoting should be used, e.g. "path/with\n and \" in it".
487
488 The value of <path> must be in canonical form. That is it must not:
489
490 · contain an empty directory component (e.g. foo//bar is
491 invalid),
492
493 · end with a directory separator (e.g. foo/ is invalid),
494
495 · start with a directory separator (e.g. /foo is invalid),
496
497 · contain the special component . or .. (e.g. foo/./bar and
498 foo/../bar are invalid).
499
500 It is recommended that <path> always be encoded using UTF-8.
501
502 filedelete
503 Included in a commit command to remove a file or recursively delete
504 an entire directory from the branch. If the file or directory
505 removal makes its parent directory empty, the parent directory will
506 be automatically removed too. This cascades up the tree until the
507 first non-empty directory or the root is reached.
508
509 ´D´ SP <path> LF
510
511 here <path> is the complete path of the file or subdirectory to be
512 removed from the branch. See filemodify above for a detailed
513 description of <path>.
514
515 filecopy
516 Recursively copies an existing file or subdirectory to a different
517 location within the branch. The existing file or directory must
518 exist. If the destination exists it will be completely replaced by
519 the content copied from the source.
520
521 ´C´ SP <path> SP <path> LF
522
523 here the first <path> is the source location and the second <path>
524 is the destination. See filemodify above for a detailed description
525 of what <path> may look like. To use a source path that contains SP
526 the path must be quoted.
527
528 A filecopy command takes effect immediately. Once the source
529 location has been copied to the destination any future commands
530 applied to the source location will not impact the destination of
531 the copy.
532
533 filerename
534 Renames an existing file or subdirectory to a different location
535 within the branch. The existing file or directory must exist. If
536 the destination exists it will be replaced by the source directory.
537
538 ´R´ SP <path> SP <path> LF
539
540 here the first <path> is the source location and the second <path>
541 is the destination. See filemodify above for a detailed description
542 of what <path> may look like. To use a source path that contains SP
543 the path must be quoted.
544
545 A filerename command takes effect immediately. Once the source
546 location has been renamed to the destination any future commands
547 applied to the source location will create new files there and not
548 impact the destination of the rename.
549
550 Note that a filerename is the same as a filecopy followed by a
551 filedelete of the source location. There is a slight performance
552 advantage to using filerename, but the advantage is so small that
553 it is never worth trying to convert a delete/add pair in source
554 material into a rename for fast-import. This filerename command is
555 provided just to simplify frontends that already have rename
556 information and don’t want bother with decomposing it into a
557 filecopy followed by a filedelete.
558
559 filedeleteall
560 Included in a commit command to remove all files (and also all
561 directories) from the branch. This command resets the internal
562 branch structure to have no files in it, allowing the frontend to
563 subsequently add all interesting files from scratch.
564
565 ´deleteall´ LF
566
567 This command is extremely useful if the frontend does not know (or
568 does not care to know) what files are currently on the branch, and
569 therefore cannot generate the proper filedelete commands to update
570 the content.
571
572 Issuing a filedeleteall followed by the needed filemodify commands
573 to set the correct content will produce the same results as sending
574 only the needed filemodify and filedelete commands. The
575 filedeleteall approach may however require fast-import to use
576 slightly more memory per active branch (less than 1 MiB for even
577 most large projects); so frontends that can easily obtain only the
578 affected paths for a commit are encouraged to do so.
579
580 notemodify
581 Included in a commit command to add a new note (annotating a given
582 commit) or change the content of an existing note. This command has
583 two different means of specifying the content of the note.
584
585 External data format
586 The data content for the note was already supplied by a prior
587 blob command. The frontend just needs to connect it to the
588 commit that is to be annotated.
589
590 ´N´ SP <dataref> SP <committish> LF
591
592 Here <dataref> can be either a mark reference (:<idnum>) set by
593 a prior blob command, or a full 40-byte SHA-1 of an existing
594 Git blob object.
595
596 Inline data format
597 The data content for the note has not been supplied yet. The
598 frontend wants to supply it as part of this modify command.
599
600 ´N´ SP ´inline´ SP <committish> LF
601 data
602
603 See below for a detailed description of the data command.
604
605 In both formats <committish> is any of the commit specification
606 expressions also accepted by from (see above).
607
608 mark
609 Arranges for fast-import to save a reference to the current object,
610 allowing the frontend to recall this object at a future point in time,
611 without knowing its SHA-1. Here the current object is the object
612 creation command the mark command appears within. This can be commit,
613 tag, and blob, but commit is the most common usage.
614
615 ´mark´ SP ´:´ <idnum> LF
616
617 where <idnum> is the number assigned by the frontend to this mark. The
618 value of <idnum> is expressed as an ASCII decimal integer. The value 0
619 is reserved and cannot be used as a mark. Only values greater than or
620 equal to 1 may be used as marks.
621
622 New marks are created automatically. Existing marks can be moved to
623 another object simply by reusing the same <idnum> in another mark
624 command.
625
626 tag
627 Creates an annotated tag referring to a specific commit. To create
628 lightweight (non-annotated) tags see the reset command below.
629
630 ´tag´ SP <name> LF
631 ´from´ SP <committish> LF
632 ´tagger´ (SP <name>)? SP LT <email> GT SP <when> LF
633 data
634
635 where <name> is the name of the tag to create.
636
637 Tag names are automatically prefixed with refs/tags/ when stored in
638 Git, so importing the CVS branch symbol RELENG-1_0-FINAL would use just
639 RELENG-1_0-FINAL for <name>, and fast-import will write the
640 corresponding ref as refs/tags/RELENG-1_0-FINAL.
641
642 The value of <name> must be a valid refname in Git and therefore may
643 contain forward slashes. As LF is not valid in a Git refname, no
644 quoting or escaping syntax is supported here.
645
646 The from command is the same as in the commit command; see above for
647 details.
648
649 The tagger command uses the same format as committer within commit;
650 again see above for details.
651
652 The data command following tagger must supply the annotated tag message
653 (see below for data command syntax). To import an empty tag message use
654 a 0 length data. Tag messages are free-form and are not interpreted by
655 Git. Currently they must be encoded in UTF-8, as fast-import does not
656 permit other encodings to be specified.
657
658 Signing annotated tags during import from within fast-import is not
659 supported. Trying to include your own PGP/GPG signature is not
660 recommended, as the frontend does not (easily) have access to the
661 complete set of bytes which normally goes into such a signature. If
662 signing is required, create lightweight tags from within fast-import
663 with reset, then create the annotated versions of those tags offline
664 with the standard git tag process.
665
666 reset
667 Creates (or recreates) the named branch, optionally starting from a
668 specific revision. The reset command allows a frontend to issue a new
669 from command for an existing branch, or to create a new branch from an
670 existing commit without creating a new commit.
671
672 ´reset´ SP <ref> LF
673 (´from´ SP <committish> LF)?
674 LF?
675
676 For a detailed description of <ref> and <committish> see above under
677 commit and from.
678
679 The LF after the command is optional (it used to be required).
680
681 The reset command can also be used to create lightweight
682 (non-annotated) tags. For example:
683
684 reset refs/tags/938
685 from :938
686
687 would create the lightweight tag refs/tags/938 referring to whatever
688 commit mark :938 references.
689
690 blob
691 Requests writing one file revision to the packfile. The revision is not
692 connected to any commit; this connection must be formed in a subsequent
693 commit command by referencing the blob through an assigned mark.
694
695 ´blob´ LF
696 mark?
697 data
698
699 The mark command is optional here as some frontends have chosen to
700 generate the Git SHA-1 for the blob on their own, and feed that
701 directly to commit. This is typically more work than it’s worth
702 however, as marks are inexpensive to store and easy to use.
703
704 data
705 Supplies raw data (for use as blob/file content, commit messages, or
706 annotated tag messages) to fast-import. Data can be supplied using an
707 exact byte count or delimited with a terminating line. Real frontends
708 intended for production-quality conversions should always use the exact
709 byte count format, as it is more robust and performs better. The
710 delimited format is intended primarily for testing fast-import.
711
712 Comment lines appearing within the <raw> part of data commands are
713 always taken to be part of the body of the data and are therefore never
714 ignored by fast-import. This makes it safe to import any file/message
715 content whose lines might start with #.
716
717 Exact byte count format
718 The frontend must specify the number of bytes of data.
719
720 ´data´ SP <count> LF
721 <raw> LF?
722
723 where <count> is the exact number of bytes appearing within <raw>.
724 The value of <count> is expressed as an ASCII decimal integer. The
725 LF on either side of <raw> is not included in <count> and will not
726 be included in the imported data.
727
728 The LF after <raw> is optional (it used to be required) but
729 recommended. Always including it makes debugging a fast-import
730 stream easier as the next command always starts in column 0 of the
731 next line, even if <raw> did not end with an LF.
732
733 Delimited format
734 A delimiter string is used to mark the end of the data. fast-import
735 will compute the length by searching for the delimiter. This format
736 is primarily useful for testing and is not recommended for real
737 data.
738
739 ´data´ SP ´<<´ <delim> LF
740 <raw> LF
741 <delim> LF
742 LF?
743
744 where <delim> is the chosen delimiter string. The string <delim>
745 must not appear on a line by itself within <raw>, as otherwise
746 fast-import will think the data ends earlier than it really does.
747 The LF immediately trailing <raw> is part of <raw>. This is one of
748 the limitations of the delimited format, it is impossible to supply
749 a data chunk which does not have an LF as its last byte.
750
751 The LF after <delim> LF is optional (it used to be required).
752
753 checkpoint
754 Forces fast-import to close the current packfile, start a new one, and
755 to save out all current branch refs, tags and marks.
756
757 ´checkpoint´ LF
758 LF?
759
760 Note that fast-import automatically switches packfiles when the current
761 packfile reaches --max-pack-size, or 4 GiB, whichever limit is smaller.
762 During an automatic packfile switch fast-import does not update the
763 branch refs, tags or marks.
764
765 As a checkpoint can require a significant amount of CPU time and disk
766 IO (to compute the overall pack SHA-1 checksum, generate the
767 corresponding index file, and update the refs) it can easily take
768 several minutes for a single checkpoint command to complete.
769
770 Frontends may choose to issue checkpoints during extremely large and
771 long running imports, or when they need to allow another Git process
772 access to a branch. However given that a 30 GiB Subversion repository
773 can be loaded into Git through fast-import in about 3 hours, explicit
774 checkpointing may not be necessary.
775
776 The LF after the command is optional (it used to be required).
777
778 progress
779 Causes fast-import to print the entire progress line unmodified to its
780 standard output channel (file descriptor 1) when the command is
781 processed from the input stream. The command otherwise has no impact on
782 the current import, or on any of fast-import’s internal state.
783
784 ´progress´ SP <any> LF
785 LF?
786
787 The <any> part of the command may contain any sequence of bytes that
788 does not contain LF. The LF after the command is optional. Callers may
789 wish to process the output through a tool such as sed to remove the
790 leading part of the line, for example:
791
792 frontend | git fast-import | sed ´s/^progress //´
793
794 Placing a progress command immediately after a checkpoint will inform
795 the reader when the checkpoint has been completed and it can safely
796 access the refs that fast-import updated.
797
798 feature
799 Require that fast-import supports the specified feature, or abort if it
800 does not.
801
802 ´feature´ SP <feature> LF
803
804 The <feature> part of the command may be any string matching
805 ^[a-zA-Z][a-zA-Z-]*$ and should be understood by fast-import.
806
807 Feature work identical as their option counterparts with the exception
808 of the import-marks feature, see below.
809
810 The following features are currently supported:
811
812 · date-format
813
814 · import-marks
815
816 · export-marks
817
818 · relative-marks
819
820 · no-relative-marks
821
822 · force
823
824 The import-marks behaves differently from when it is specified as
825 commandline option in that only one "feature import-marks" is allowed
826 per stream. Also, any --import-marks= specified on the commandline will
827 override those from the stream (if any).
828
829 option
830 Processes the specified option so that git fast-import behaves in a way
831 that suits the frontend’s needs. Note that options specified by the
832 frontend are overridden by any options the user may specify to git
833 fast-import itself.
834
835 ´option´ SP <option> LF
836
837 The <option> part of the command may contain any of the options listed
838 in the OPTIONS section that do not change import semantics, without the
839 leading -- and is treated in the same way.
840
841 Option commands must be the first commands on the input (not counting
842 feature commands), to give an option command after any non-option
843 command is an error.
844
845 The following commandline options change import semantics and may
846 therefore not be passed as option:
847
848 · date-format
849
850 · import-marks
851
852 · export-marks
853
854 · force
855
857 If fast-import is supplied invalid input it will terminate with a
858 non-zero exit status and create a crash report in the top level of the
859 Git repository it was importing into. Crash reports contain a snapshot
860 of the internal fast-import state as well as the most recent commands
861 that lead up to the crash.
862
863 All recent commands (including stream comments, file changes and
864 progress commands) are shown in the command history within the crash
865 report, but raw file data and commit messages are excluded from the
866 crash report. This exclusion saves space within the report file and
867 reduces the amount of buffering that fast-import must perform during
868 execution.
869
870 After writing a crash report fast-import will close the current
871 packfile and export the marks table. This allows the frontend developer
872 to inspect the repository state and resume the import from the point
873 where it crashed. The modified branches and tags are not updated during
874 a crash, as the import did not complete successfully. Branch and tag
875 information can be found in the crash report and must be applied
876 manually if the update is needed.
877
878 An example crash:
879
880 $ cat >in <<END_OF_INPUT
881 # my very first test commit
882 commit refs/heads/master
883 committer Shawn O. Pearce <spearce> 19283 -0400
884 # who is that guy anyway?
885 data <<EOF
886 this is my commit
887 EOF
888 M 644 inline .gitignore
889 data <<EOF
890 .gitignore
891 EOF
892 M 777 inline bob
893 END_OF_INPUT
894
895 $ git fast-import <in
896 fatal: Corrupt mode: M 777 inline bob
897 fast-import: dumping crash report to .git/fast_import_crash_8434
898
899 $ cat .git/fast_import_crash_8434
900 fast-import crash report:
901 fast-import process: 8434
902 parent process : 1391
903 at Sat Sep 1 00:58:12 2007
904
905 fatal: Corrupt mode: M 777 inline bob
906
907 Most Recent Commands Before Crash
908 ---------------------------------
909 # my very first test commit
910 commit refs/heads/master
911 committer Shawn O. Pearce <spearce> 19283 -0400
912 # who is that guy anyway?
913 data <<EOF
914 M 644 inline .gitignore
915 data <<EOF
916 * M 777 inline bob
917
918 Active Branch LRU
919 -----------------
920 active_branches = 1 cur, 5 max
921
922 pos clock name
923 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
924 1) 0 refs/heads/master
925
926 Inactive Branches
927 -----------------
928 refs/heads/master:
929 status : active loaded dirty
930 tip commit : 0000000000000000000000000000000000000000
931 old tree : 0000000000000000000000000000000000000000
932 cur tree : 0000000000000000000000000000000000000000
933 commit clock: 0
934 last pack :
935
936 -------------------
937 END OF CRASH REPORT
938
940 The following tips and tricks have been collected from various users of
941 fast-import, and are offered here as suggestions.
942
943 Use One Mark Per Commit
944 When doing a repository conversion, use a unique mark per commit (mark
945 :<n>) and supply the --export-marks option on the command line.
946 fast-import will dump a file which lists every mark and the Git object
947 SHA-1 that corresponds to it. If the frontend can tie the marks back to
948 the source repository, it is easy to verify the accuracy and
949 completeness of the import by comparing each Git commit to the
950 corresponding source revision.
951
952 Coming from a system such as Perforce or Subversion this should be
953 quite simple, as the fast-import mark can also be the Perforce
954 changeset number or the Subversion revision number.
955
956 Freely Skip Around Branches
957 Don’t bother trying to optimize the frontend to stick to one branch at
958 a time during an import. Although doing so might be slightly faster for
959 fast-import, it tends to increase the complexity of the frontend code
960 considerably.
961
962 The branch LRU builtin to fast-import tends to behave very well, and
963 the cost of activating an inactive branch is so low that bouncing
964 around between branches has virtually no impact on import performance.
965
966 Handling Renames
967 When importing a renamed file or directory, simply delete the old
968 name(s) and modify the new name(s) during the corresponding commit. Git
969 performs rename detection after-the-fact, rather than explicitly during
970 a commit.
971
972 Use Tag Fixup Branches
973 Some other SCM systems let the user create a tag from multiple files
974 which are not from the same commit/changeset. Or to create tags which
975 are a subset of the files available in the repository.
976
977 Importing these tags as-is in Git is impossible without making at least
978 one commit which “fixes up” the files to match the content of the tag.
979 Use fast-import’s reset command to reset a dummy branch outside of your
980 normal branch space to the base commit for the tag, then commit one or
981 more file fixup commits, and finally tag the dummy branch.
982
983 For example since all normal branches are stored under refs/heads/ name
984 the tag fixup branch TAG_FIXUP. This way it is impossible for the fixup
985 branch used by the importer to have namespace conflicts with real
986 branches imported from the source (the name TAG_FIXUP is not
987 refs/heads/TAG_FIXUP).
988
989 When committing fixups, consider using merge to connect the commit(s)
990 which are supplying file revisions to the fixup branch. Doing so will
991 allow tools such as git blame to track through the real commit history
992 and properly annotate the source files.
993
994 After fast-import terminates the frontend will need to do rm
995 .git/TAG_FIXUP to remove the dummy branch.
996
997 Import Now, Repack Later
998 As soon as fast-import completes the Git repository is completely valid
999 and ready for use. Typically this takes only a very short time, even
1000 for considerably large projects (100,000+ commits).
1001
1002 However repacking the repository is necessary to improve data locality
1003 and access performance. It can also take hours on extremely large
1004 projects (especially if -f and a large --window parameter is used).
1005 Since repacking is safe to run alongside readers and writers, run the
1006 repack in the background and let it finish when it finishes. There is
1007 no reason to wait to explore your new Git project!
1008
1009 If you choose to wait for the repack, don’t try to run benchmarks or
1010 performance tests until repacking is completed. fast-import outputs
1011 suboptimal packfiles that are simply never seen in real use situations.
1012
1013 Repacking Historical Data
1014 If you are repacking very old imported data (e.g. older than the last
1015 year), consider expending some extra CPU time and supplying --window=50
1016 (or higher) when you run git repack. This will take longer, but will
1017 also produce a smaller packfile. You only need to expend the effort
1018 once, and everyone using your project will benefit from the smaller
1019 repository.
1020
1021 Include Some Progress Messages
1022 Every once in a while have your frontend emit a progress message to
1023 fast-import. The contents of the messages are entirely free-form, so
1024 one suggestion would be to output the current month and year each time
1025 the current commit date moves into the next month. Your users will feel
1026 better knowing how much of the data stream has been processed.
1027
1029 When packing a blob fast-import always attempts to deltify against the
1030 last blob written. Unless specifically arranged for by the frontend,
1031 this will probably not be a prior version of the same file, so the
1032 generated delta will not be the smallest possible. The resulting
1033 packfile will be compressed, but will not be optimal.
1034
1035 Frontends which have efficient access to all revisions of a single file
1036 (for example reading an RCS/CVS ,v file) can choose to supply all
1037 revisions of that file as a sequence of consecutive blob commands. This
1038 allows fast-import to deltify the different file revisions against each
1039 other, saving space in the final packfile. Marks can be used to later
1040 identify individual file revisions during a sequence of commit
1041 commands.
1042
1043 The packfile(s) created by fast-import do not encourage good disk
1044 access patterns. This is caused by fast-import writing the data in the
1045 order it is received on standard input, while Git typically organizes
1046 data within packfiles to make the most recent (current tip) data appear
1047 before historical data. Git also clusters commits together, speeding up
1048 revision traversal through better cache locality.
1049
1050 For this reason it is strongly recommended that users repack the
1051 repository with git repack -a -d after fast-import completes, allowing
1052 Git to reorganize the packfiles for faster data access. If blob deltas
1053 are suboptimal (see above) then also adding the -f option to force
1054 recomputation of all deltas can significantly reduce the final packfile
1055 size (30-50% smaller can be quite typical).
1056
1058 There are a number of factors which affect how much memory fast-import
1059 requires to perform an import. Like critical sections of core Git,
1060 fast-import uses its own memory allocators to amortize any overheads
1061 associated with malloc. In practice fast-import tends to amortize any
1062 malloc overheads to 0, due to its use of large block allocations.
1063
1064 per object
1065 fast-import maintains an in-memory structure for every object written
1066 in this execution. On a 32 bit system the structure is 32 bytes, on a
1067 64 bit system the structure is 40 bytes (due to the larger pointer
1068 sizes). Objects in the table are not deallocated until fast-import
1069 terminates. Importing 2 million objects on a 32 bit system will require
1070 approximately 64 MiB of memory.
1071
1072 The object table is actually a hashtable keyed on the object name (the
1073 unique SHA-1). This storage configuration allows fast-import to reuse
1074 an existing or already written object and avoid writing duplicates to
1075 the output packfile. Duplicate blobs are surprisingly common in an
1076 import, typically due to branch merges in the source.
1077
1078 per mark
1079 Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
1080 bytes, depending on pointer size) per mark. Although the array is
1081 sparse, frontends are still strongly encouraged to use marks between 1
1082 and n, where n is the total number of marks required for this import.
1083
1084 per branch
1085 Branches are classified as active and inactive. The memory usage of the
1086 two classes is significantly different.
1087
1088 Inactive branches are stored in a structure which uses 96 or 120 bytes
1089 (32 bit or 64 bit systems, respectively), plus the length of the branch
1090 name (typically under 200 bytes), per branch. fast-import will easily
1091 handle as many as 10,000 inactive branches in under 2 MiB of memory.
1092
1093 Active branches have the same overhead as inactive branches, but also
1094 contain copies of every tree that has been recently modified on that
1095 branch. If subtree include has not been modified since the branch
1096 became active, its contents will not be loaded into memory, but if
1097 subtree src has been modified by a commit since the branch became
1098 active, then its contents will be loaded in memory.
1099
1100 As active branches store metadata about the files contained on that
1101 branch, their in-memory storage size can grow to a considerable size
1102 (see below).
1103
1104 fast-import automatically moves active branches to inactive status
1105 based on a simple least-recently-used algorithm. The LRU chain is
1106 updated on each commit command. The maximum number of active branches
1107 can be increased or decreased on the command line with
1108 --active-branches=.
1109
1110 per active tree
1111 Trees (aka directories) use just 12 bytes of memory on top of the
1112 memory required for their entries (see “per active file” below). The
1113 cost of a tree is virtually 0, as its overhead amortizes out over the
1114 individual file entries.
1115
1116 per active file entry
1117 Files (and pointers to subtrees) within active trees require 52 or 64
1118 bytes (32/64 bit platforms) per entry. To conserve space, file and tree
1119 names are pooled in a common string table, allowing the filename
1120 “Makefile” to use just 16 bytes (after including the string header
1121 overhead) no matter how many times it occurs within the project.
1122
1123 The active branch LRU, when coupled with the filename string pool and
1124 lazy loading of subtrees, allows fast-import to efficiently import
1125 projects with 2,000+ branches and 45,114+ files in a very limited
1126 memory footprint (less than 2.7 MiB per active branch).
1127
1129 Written by Shawn O. Pearce <spearce@spearce.org[2]>.
1130
1132 Documentation by Shawn O. Pearce <spearce@spearce.org[2]>.
1133
1135 Part of the git(1) suite
1136
1138 1. cm@example.com
1139 mailto:cm@example.com
1140
1141 2. spearce@spearce.org
1142 mailto:spearce@spearce.org
1143
1144
1145
1146Git 1.7.1 08/16/2017 GIT-FAST-IMPORT(1)