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