.\" generated with Ronn-NG/v0.9.1 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 .TH "GIT\-LFS\-MIGRATE" "1" "July 2021" "" .SH "NAME" \fBgit\-lfs\-migrate\fR \- Migrate history to or from git\-lfs .SH "SYNOPSIS" \fBgit lfs migrate\fR \fImode\fR [options] [\-\-] [branch \|\.\|\.\|\.] .SH "MODES" .IP "\[ci]" 4 \fBinfo\fR Show information about repository size\. .IP "\[ci]" 4 \fBimport\fR Convert large Git objects to LFS pointers\. .IP "\[ci]" 4 \fBexport\fR Convert LFS pointers to large Git objects\. .IP "" 0 .SH "OPTIONS" .TP \fB\-I\fR \fIpaths\fR \fB\-\-include=\fR\fIpaths\fR See \fIINCLUDE AND EXCLUDE\fR\. .TP \fB\-X\fR \fIpaths\fR \fB\-\-exclude=\fR\fIpaths\fR See \fIINCLUDE AND EXCLUDE\fR\. .TP \fB\-\-include\-ref\fR=\fIrefname\fR See [INCLUDE AND EXCLUDE (REFS)]\. .TP \fB\-\-exclude\-ref\fR=\fIrefname\fR See [INCLUDE AND EXCLUDE (REFS)]\. .TP \fB\-\-skip\-fetch\fR Assumes that the known set of remote references is complete, and should not be refreshed when determining the set of "un\-pushed" commits to migrate\. Has no effect when combined with \fB\-\-include\-ref\fR or \fB\-\-exclude\-ref\fR\. .TP \fB\-\-everything\fR See [INCLUDE AND EXCLUDE (REFS)]\. .IP Note: Git refs are "case\-sensitive" on all platforms in "packed from" (see \fBgit\-pack\-refs(1)\fR)\. On "case\-insensitive" file systems, e\.g\. NTFS on Windows or default APFS on macOS, \fBgit\-lfs\-migrate(1)\fR would only migrate the first ref if two or more refs are equal except for upper/lower case letters\. .TP \fB\-\-yes\fR Assume a yes answer to any prompts, permitting noninteractive use\. Currently, the only such prompt is the one asking whether to overwrite (destroy) any working copy changes\. Thus, specifying this option may cause data loss if you are not careful\. .TP [branch \|\.\|\.\|\.] Migrate only the set of branches listed\. If not given, \fBgit\-lfs\-migrate(1)\fR will migrate the currently checked out branch\. .IP References beginning with '^' will be excluded, whereas branches that do not begin with '^' will be included\. .IP If any of \fB\-\-include\-ref\fR or \fB\-\-exclude\-ref\fR are given, the checked out branch will not be appended, but branches given explicitly will be appended\. .SS "INFO" The 'info' mode has these additional options: .IP "\[ci]" 4 \fB\-\-above=\fR Only count files whose individual filesize is above the given size\. 'size' may be specified as a number of bytes, or a number followed by a storage unit, e\.g\., "1b", "20 MB", "3 TiB", etc\. .IP If a set of files sharing a common extension has no files in that set whose individual size is above the given \fB\-\-above\fR no files no entry for that set will be shown\. .IP "\[ci]" 4 \fB\-\-top=\fR Only include the top 'n' entries, ordered by how many total files match the given pathspec\. Default: top 5 entries\. .IP "\[ci]" 4 \fB\-\-unit=\fR Format the number of bytes in each entry as a quantity of the storage unit provided\. Valid units include: * b, kib, mib, gib, tib, pib \- for IEC storage units * b, kb, mb, gb, tb, pb \- for SI storage units .IP If a \-\-unit is not specified, the largest unit that can fit the number of counted bytes as a whole number quantity is chosen\. .IP "" 0 .SS "IMPORT" The 'import' mode migrates large objects present in the Git history to pointer files tracked and stored with Git LFS\. It supports all the core 'migrate' options and these additional ones: .IP "\[ci]" 4 \fB\-\-verbose\fR Print the commit oid and filename of migrated files to STDOUT\. .IP "\[ci]" 4 \fB\-\-above=\fR Only migrate files whose individual filesize is above the given size\. 'size' may be specified as a number of bytes, or a number followed by a storage unit, e\.g\., "1b", "20 MB", "3 TiB", etc\. .IP "\[ci]" 4 \fB\-\-object\-map=\fR Write to 'path' a file with the mapping of each rewritten commits\. The file format is CSV with this pattern: \fBOLD\-SHA\fR,\fBNEW\-SHA\fR .IP "\[ci]" 4 \fB\-\-no\-rewrite\fR Migrate large objects to Git LFS in a new commit without rewriting git history\. Please note that when this option is used, the \fBmigrate import\fR command will expect a different argument list, specialized options will become available, and the core \fBmigrate\fR options will be ignored\. See [IMPORT (NO REWRITE)]\. .IP "\[ci]" 4 \fB\-\-fixup\fR Infer \fB\-\-include\fR and \fB\-\-exclude\fR filters on a per\-commit basis based on the \.gitattributes files in a repository\. In practice, this option imports any filepaths which should be tracked by Git LFS according to the repository's \.gitattributes file(s), but aren't already pointers\. This option is incompatible with explicitly given \fB\-\-include\fR, \fB\-\-exclude\fR filters\. .IP "" 0 .P If \fB\-\-no\-rewrite\fR is not provided and \fB\-\-include\fR or \fB\-\-exclude\fR (\fB\-I\fR, \fB\-X\fR, respectively) are given, the \.gitattributes will be modified to include any new filepath patterns as given by those flags\. .P If \fB\-\-no\-rewrite\fR is not provided and neither of those flags are given, the gitattributes will be incrementally modified to include new filepath extensions as they are rewritten in history\. .SS "IMPORT (NO REWRITE)" The \fBimport\fR mode has a special sub\-mode enabled by the \fB\-\-no\-rewrite\fR flag\. This sub\-mode will migrate large objects to pointers as in the base \fBimport\fR mode, but will do so in a new commit without rewriting Git history\. When using this sub\-mode, the base \fBmigrate\fR options, such as \fB\-\-include\-ref\fR, will be ignored, as will those for the base \fBimport\fR mode\. The \fBmigrate\fR command will also take a different argument list\. As a result of these changes, \fB\-\-no\-rewrite\fR will only operate on the current branch \- any other interested branches must have the generated commit merged in\. .P The \fB\-\-no\-rewrite\fR sub\-mode supports the following options and arguments: .IP "\[ci]" 4 \fB\-m \-\-message=\fR Specifies a commit message for the newly created commit\. .IP "\[ci]" 4 [file \|\.\|\.\|\.] The list of files to import\. These files must be tracked by patterns specified in the gitattributes\. .IP "" 0 .P If \fB\-\-message\fR is given, the new commit will be created with the provided message\. If no message is given, a commit message will be generated based on the file arguments\. .SS "EXPORT" The 'export' mode migrates Git LFS pointer files present in the Git history out of Git LFS, converting them into their corresponding object files\. It supports all the core 'migrate' options and these additional ones: .IP "\[ci]" 4 \fB\-\-verbose\fR Print the commit oid and filename of migrated files to STDOUT\. .IP "\[ci]" 4 \fB\-\-object\-map=\fR Write to 'path' a file with the mapping of each rewritten commit\. The file format is CSV with this pattern: \fBOLD\-SHA\fR,\fBNEW\-SHA\fR .IP "\[ci]" 4 \fB\-\-remote=\fR Download LFS objects from the provided 'git\-remote' during the export\. If not provided, defaults to 'origin'\. .IP "" 0 .P The 'export' mode requires at minimum a pattern provided with the \fB\-\-include\fR argument to specify which files to export\. Files matching the \fB\-\-include\fR patterns will be removed from Git LFS, while files matching the \fB\-\-exclude\fR patterns will retain their Git LFS status\. The export command will modify the \.gitattributes to set/unset any filepath patterns as given by those flags\. .SH "INCLUDE AND EXCLUDE" You can configure Git LFS to only migrate tree entries whose pathspec matches the include glob and does not match the exclude glob, to reduce total migration time or to only migrate part of your repo\. Specify multiple patterns using the comma as the delimiter\. .P Pattern matching is done as given to be functionally equivalent to pattern matching as in \.gitattributes\. .SH "INCLUDE AND EXCLUDE (REFS)" You can configure Git LFS to only migrate commits reachable by references include by \fB\-\-include\-ref\fR and not reachable by \fB\-\-exclude\-ref\fR\. .P \fBD\-\-\-E\-\-\-F / \e A\-\-\-B\-\-\-\-\-\-C refs/heads/my\-feature \e \e \e refs/heads/master \e refs/remotes/origin/master\fR .P In the above configuration, the following commits are reachable by each ref: .P \fBrefs/heads/master: C, B, A refs/heads/my\-feature: F, E, D, B, A refs/remote/origin/master: A\fR .P The following configuration: .P \fB\-\-include\-ref=refs/heads/my\-feature \-\-include\-ref=refs/heads/master \-\-exclude\-ref=refs/remotes/origin/master\fR .P Would, therefore, include commits: F, E, D, C, B, but exclude commit A\. .P The presence of flag \fB\-\-everything\fR indicates that all local and remote references should be migrated\. .SH "EXAMPLES" .SS "Migrate unpushed commits" The migrate command's most common use case is to convert large git objects to LFS before pushing your commits\. By default, it only scans commits that don't exist on any remote, so long as the repository is non\-bare\. .P First, run \fBgit lfs migrate info\fR to list the file types taking up the most space in your repository\. .P \fB$ git lfs migrate info migrate: Fetching remote refs: \|\.\|\.\|\., done migrate: Sorting commits: \|\.\|\.\|\., done migrate: Examining commits: 100% (1/1), done *\.mp3 284 MB 1/1 files(s) 100% *\.pdf 42 MB 8/8 files(s) 100% *\.psd 9\.8 MB 15/15 files(s) 100% *\.ipynb 6\.9 MB 6/6 files(s) 100% *\.csv 5\.8 MB 2/2 files(s) 100%\fR .P Now, you can run \fBgit lfs migrate import\fR to convert some file types to LFS: .P \fB$ git lfs migrate import \-\-include="*\.mp3,*\.psd" migrate: Fetching remote refs: \|\.\|\.\|\., done migrate: Sorting commits: \|\.\|\.\|\., done migrate: Rewriting commits: 100% (1/1), done master d2b959babd099fe70da1c1512e2475e8a24de163 \-> 136e706bf1ae79643915c134e17a6c933fd53c61 migrate: Updating refs: \|\.\|\.\|\., done\fR .SS "Migrate local history" You can also migrate the entire history of your repository: .P ``` # Check for large files in your local master branch $ git lfs migrate info \-\-include\-ref=master$ git lfs migrate info \-\-everything ``` .P The same flags will work in \fBimport\fR mode: .P ``` # Convert all zip files in your master branch $ git lfs migrate import \-\-include\-ref=master \-\-include="*\.zip"$ git lfs migrate import \-\-everything \-\-include="*\.zip"$ git lfs migrate import \-\-everything \-\-above=100Kb ``` .P Note: This will require a force push to any existing Git remotes\. .SS "Migrate without rewriting local history" You can also migrate files without modifying the existing history of your repository\. Note that in the examples below, files in subdirectories are not included because they are not explicitly specified\. .P Without a specified commit message: .P \fB$ git lfs migrate import \-\-no\-rewrite test\.zip *\.mp3 *\.psd\fR .P With a specified commit message: .P \fB$ git lfs migrate import \-\-no\-rewrite \e \-m "Import test\.zip, \.mp3, \.psd files in root of repo" \e test\.zip *\.mp3 *\.psd\fR .SH "SEE ALSO" Part of the git\-lfs(1) suite\.