Home Explore Blog CI



git

10th chunk of `Documentation/git-fast-import.adoc`
13fcb0dd48ab621d104dd761daeaf4fc282e42eca04ebd200000000100000fa1
 as `\n`, backslash
as `\\`, and double quote as `\"`. Some characters may optionally be
written with escape sequences: `\a` for bell, `\b` for backspace, `\f`
for form feed, `\n` for line feed, `\r` for carriage return, `\t` for
horizontal tab, and `\v` for vertical tab. Any byte can be written with
3-digit octal codes (e.g., `\033`). All filenames can be represented as
quoted strings.

A `<path>` must use UNIX-style directory separators (forward slash `/`)
and its value must be in canonical form. That is it must not:

* contain an empty directory component (e.g. `foo//bar` is invalid),
* end with a directory separator (e.g. `foo/` is invalid),
* start with a directory separator (e.g. `/foo` is invalid),
* contain the special component `.` or `..` (e.g. `foo/./bar` and
  `foo/../bar` are invalid).

The root of the tree can be represented by an empty string as `<path>`.

`<path>` cannot contain NUL, either literally or escaped as `\000`.
It is recommended that `<path>` always be encoded using UTF-8.

`filedelete`
^^^^^^^^^^^^
Included in a `commit` command to remove a file or recursively
delete an entire directory from the branch.  If the file or directory
removal makes its parent directory empty, the parent directory will
be automatically removed too.  This cascades up the tree until the
first non-empty directory or the root is reached.

....
	'D' SP <path> LF
....

here `<path>` is the complete path of the file or subdirectory to
be removed from the branch.
See `filemodify` above for a detailed description of `<path>`.

`filecopy`
^^^^^^^^^^
Recursively copies an existing file or subdirectory to a different
location within the branch.  The existing file or directory must
exist.  If the destination exists it will be completely replaced
by the content copied from the source.

....
	'C' SP <path> SP <path> LF
....

here the first `<path>` is the source location and the second
`<path>` is the destination.  See `filemodify` above for a detailed
description of what `<path>` may look like.  To use a source path
that contains SP the path must be quoted.

A `filecopy` command takes effect immediately.  Once the source
location has been copied to the destination any future commands
applied to the source location will not impact the destination of
the copy.

`filerename`
^^^^^^^^^^^^
Renames an existing file or subdirectory to a different location
within the branch.  The existing file or directory must exist. If
the destination exists it will be replaced by the source directory.

....
	'R' SP <path> SP <path> LF
....

here the first `<path>` is the source location and the second
`<path>` is the destination.  See `filemodify` above for a detailed
description of what `<path>` may look like.  To use a source path
that contains SP the path must be quoted.

A `filerename` command takes effect immediately.  Once the source
location has been renamed to the destination any future commands
applied to the source location will create new files there and not
impact the destination of the rename.

Note that a `filerename` is the same as a `filecopy` followed by a
`filedelete` of the source location.  There is a slight performance
advantage to using `filerename`, but the advantage is so small
that it is never worth trying to convert a delete/add pair in
source material into a rename for fast-import.  This `filerename`
command is provided just to simplify frontends that already have
rename information and don't want bother with decomposing it into a
`filecopy` followed by a `filedelete`.

`filedeleteall`
^^^^^^^^^^^^^^^
Included in a `commit` command to remove all files (and also all
directories) from the branch.  This command resets the internal
branch structure to have no files in it, allowing the frontend
to subsequently add all interesting files from scratch.

....
	'deleteall' LF
....

This command is extremely useful if the frontend does not know
(or does not care to know) what files are currently on the branch,
and therefore cannot generate the

Title: Git Fast Import File Commands
Summary
The git-fast-import command provides options for file management, including deleting files or directories, copying files or directories, renaming files or directories, and deleting all files and directories, with specific syntax and rules for specifying file paths and handling special characters, all of which can be used to modify the branch structure and content.