|
NAMEgit-lfs-migrate - Migrate history to or from Git LFSSYNOPSISgit lfs migrate mode [options] [--] [branch ...]DESCRIPTIONConvert files in a Git repository to or from Git LFS pointers, or summarize Git file sizes by file type. The import mode converts Git files (i.e., blobs) to Git LFS, while the export mode does the reverse, and the info mode provides an informational summary which may be useful in deciding which files to import or export.In all modes, by default git lfs migrate operates only on the currently checked-out branch, and only on files (of any size and type) added in commits which do not exist on any remote. Multiple options are available to override these defaults. When converting files to or from Git LFS, the git lfs migrate command will only make changes to your local repository and working copy, never any remotes. This is intentional as the import and export modes are generally "destructive" in the sense that they rewrite your Git history, changing commits and generating new commit SHAs. (The exception is the "no-rewrite" import sub-mode; see [IMPORT (NO REWRITE)] for details.) You should therefore always first commit or stash any uncommitted work before using the import or export modes, and then validate the result of the migration before pushing the changes to your remotes, for instance by running the info mode and by examining your rewritten commit history. Once you are satisfied with the changes, you will need to force-push the new Git history of any rewritten branches to all your remotes. This is a step which should be taken with care, since you will be altering the Git history on your remotes. To examine or modify files in branches other than the currently checked-out one, branch refs may be specified directly, or provided in one or more --include-ref options. They may also be excluded by prefixing them with ^ or providing them in --exclude-ref options. Use the --everything option to specify that all refs should be examined, including all remote refs. See [INCLUDE AND EXCLUDE (REFS)] for details. For the info and import modes, all file types are considered by default; while useful in the info mode, this is often not desirable when importing, so either filename patterns (pathspecs) or the --fixup option should normally be specified in that case. (At least one include pathspec is required for the export mode.) Pathspecs may be defined using the --include and --exclude options (-I and -X for short), as described in INCLUDE AND EXCLUDE. As typical Git LFS usage depends on tracking specific file types using filename patterns defined in .gitattributes files, the git lfs migrate command will examine, create, and modify .gitattributes files as necessary. The import mode (see IMPORT) will convert Git objects of the file types specified (e.g., with --include) to Git LFS pointers, and will add entries for those file types to .gitattributes files, creating those files if they do not exist. The result should be as if git lfs track commands had been run at the points in your Git history corresponding to where each type of converted file first appears. The exception is if the --fixup option is given, in which case the import mode will only examine any existing .gitattributes files and then convert Git objects which should be tracked by Git LFS but are not yet. The export mode (see EXPORT) works as the reverse operation to the import mode, converting any Git LFS pointers that match the file types specified with --include, which must be given at least once. Note that .gitattributes entries will not be removed, nor will the files; instead, the export mode inserts "do not track" entries similar to those created by the git lfs untrack command. The --remote option is available in the export mode to specify the remote from which Git LFS objects should be fetched if they do not exist in the local Git LFS object cache; if not provided, origin is used by default. The info mode (see INFO) summarizes by file type (i.e., by filename extension) the total number and size of files in a repository. Note that like the other two modes, by default the info mode operates only on the currently checked-out branch and only on commits which do not exist on any remote, so to get a summary of the entire repository across all branches, use the --everything option. If objects have already been converted to Git LFS pointers, then by default the size of the referenced objects is totaled and reported separately. You may also choose to ignore them by using --pointers=ignore or to treat the pointers as files by using --pointers=no-follow. (The latter option is akin to how existing Git LFS pointers were handled by the info mode in prior versions of Git LFS). When using the --everything option, take note that it means all refs (local and remote) will be considered, but not necessarily all file types. The import and info modes consider all file types by default, although the --include and --exclude options constrain this behavior. Also note that after importing across all branches with the --everything option (and then checking to ensure the results are satisfactory!) it may be convenient to update multiple branches on your remotes by using the --all option to git push. Unless the --skip-fetch option is given, git lfs migrate always begins by fetching updated lists of refs from all the remotes returned by git remote, but as noted above, after making changes to your local Git history while converting objects, it will never automatically push those changes to your remotes. MODES
OPTIONS
INFOThe info mode summarizes the sizes of file objects present in the Git history. It supports all the core migrate options and these additional ones:
The format of the output shows the filename pattern, the total size of the file objects (excluding those below the --above threshold, if one was defined), and the ratio of the number of files above the threshold to the total number of files; this ratio is also shown as a percentage. For example:
By default only the top five entries are shown, but --top allows for more or fewer to be output as desired. IMPORTThe import mode migrates 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:
If --no-rewrite is not provided and --include or --exclude (-I, -X, respectively) are given, the .gitattributes will be modified to include any new filepath patterns as given by those flags. If --no-rewrite 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. IMPORT (NO REWRITE)The import mode has a special sub-mode enabled by the --no-rewrite flag. This sub-mode will migrate objects to pointers as in the base import mode, but will do so in a new commit without rewriting Git history. When using this sub-mode, the base migrate options, such as --include-ref, will be ignored, as will those for the base import mode. The migrate command will also take a different argument list. As a result of these changes, --no-rewrite will only operate on the current branch - any other interested branches must have the generated commit merged in.The --no-rewrite sub-mode supports the following options and arguments:
If --message 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. EXPORTThe 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:
The export mode requires at minimum a pattern provided with the --include argument to specify which files to export. Files matching the --include patterns will be removed from Git LFS, while files matching the --exclude 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. INCLUDE AND EXCLUDEYou can specify that git lfs migrate should only convert files whose pathspec matches the --include glob patterns and does not match the --exclude glob patterns, either to reduce total migration time or to only migrate part of your repo. Multiple patterns may be given using commas as delimiters.Pattern matching is done so as to be functionally equivalent to the pattern matching format of .gitattributes. In addition to simple file extension matches (e.g., *.gif) patterns may also specify directory paths, in which case the path/** format may be used to match recursively. INCLUDE AND EXCLUDE (REFS)You can specify that git lfs migrate should only convert files added in commits reachable from certain references, namely those defined using one or more --include-ref options, and should ignore files in commits reachable from references defined in --exclude-ref options.
In the above configuration, the following commits are reachable by each ref:
The following git lfs migrate options would, therefore, include commits F, E, D, C, and B, but exclude commit A:
The presence of flag --everything indicates that all local and remote references should be migrated. EXAMPLESMigrate unpushed commitsA common use case for the migrate command 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.First, run git lfs migrate info to list the file types taking up the most space in your repository:
Now, you can run git lfs migrate import to convert some file types to LFS:
If after conversion you find that some files in your working directory have been replaced with Git LFS pointers, this is normal, and the working copies of these files can be repopulated with their full expected contents by using git lfs checkout. Migrate local historyYou can also migrate the entire history of your repository:
The same flags will work in import mode:
Note: This will require a force-push to any existing Git remotes. Using the --all option when force-pushing may be convenient if many refs were updated, e.g., after importing to Git LFS with the --everything option. Migrate without rewriting local historyYou 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.Without a specified commit message:
With a specified commit message:
SEE ALSOgit-lfs-checkout(1), git-lfs-track(1), git-lfs-untrack(1), gitattributes(5).Part of the git-lfs(1) suite.
Visit the GSP FreeBSD Man Page Interface. |