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