|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta http-equiv='content-type' value='text/html;charset=utf8'> |
|
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'> |
|
<title>git-lfs-migrate(1) - Migrate history to or from Git LFS</title> |
|
<style type='text/css' media='all'> |
|
|
|
body#manpage {margin:0} |
|
.mp {max-width:100ex;padding:0 9ex 1ex 4ex} |
|
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0} |
|
.mp h2 {margin:10px 0 0 0} |
|
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex} |
|
.mp h3 {margin:0 0 0 4ex} |
|
.mp dt {margin:0;clear:left} |
|
.mp dt.flush {float:left;width:8ex} |
|
.mp dd {margin:0 0 0 9ex} |
|
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left} |
|
.mp pre {margin-bottom:20px} |
|
.mp pre+h2,.mp pre+h3 {margin-top:22px} |
|
.mp h2+pre,.mp h3+pre {margin-top:5px} |
|
.mp img {display:block;margin:auto} |
|
.mp h1.man-title {display:none} |
|
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143} |
|
.mp h2 {font-size:16px;line-height:1.25} |
|
.mp h1 {font-size:20px;line-height:2} |
|
.mp {text-align:justify;background:#fff} |
|
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211} |
|
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201} |
|
.mp u {text-decoration:underline} |
|
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211} |
|
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none} |
|
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff} |
|
.mp b.man-ref {font-weight:normal;color:#434241} |
|
.mp pre {padding:0 4ex} |
|
.mp pre code {font-weight:normal;color:#434241} |
|
.mp h2+pre,h3+pre {padding-left:0} |
|
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px} |
|
ol.man-decor {width:100%} |
|
ol.man-decor li.tl {text-align:left} |
|
ol.man-decor li.tc {text-align:center;letter-spacing:4px} |
|
ol.man-decor li.tr {text-align:right;float:right} |
|
</style> |
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body id='manpage'> |
|
<div class='mp' id='man'> |
|
|
|
<div class='man-navigation' style='display:none'> |
|
<a href="#NAME">NAME</a> |
|
<a href="#SYNOPSIS">SYNOPSIS</a> |
|
<a href="#DESCRIPTION">DESCRIPTION</a> |
|
<a href="#MODES">MODES</a> |
|
<a href="#OPTIONS">OPTIONS</a> |
|
<a href="#INCLUDE-AND-EXCLUDE">INCLUDE AND EXCLUDE</a> |
|
<a href="#INCLUDE-AND-EXCLUDE-REFS-">INCLUDE AND EXCLUDE (REFS)</a> |
|
<a href="#EXAMPLES">EXAMPLES</a> |
|
<a href="#SEE-ALSO">SEE ALSO</a> |
|
</div> |
|
|
|
<ol class='man-decor man-head man head'> |
|
<li class='tl'>git-lfs-migrate(1)</li> |
|
<li class='tc'></li> |
|
<li class='tr'>git-lfs-migrate(1)</li> |
|
</ol> |
|
|
|
<h2 id="NAME">NAME</h2> |
|
<p class="man-name"> |
|
<code>git-lfs-migrate</code> - <span class="man-whatis">Migrate history to or from Git LFS</span> |
|
</p> |
|
|
|
<h2 id="SYNOPSIS">SYNOPSIS</h2> |
|
|
|
<p><code>git lfs migrate</code> <var>mode</var> [options] [--] [branch ...]</p> |
|
|
|
<h2 id="DESCRIPTION">DESCRIPTION</h2> |
|
|
|
<p>Convert files in a Git repository to or from Git LFS pointers, or |
|
summarize Git file sizes by file type. The <code>import</code> mode converts Git |
|
files (i.e., blobs) to Git LFS, while the <code>export</code> mode does the reverse, |
|
and the <code>info</code> mode provides an informational summary which may be useful |
|
in deciding which files to import or export.</p> |
|
|
|
<p>In all modes, by default <code>git lfs migrate</code> 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.</p> |
|
|
|
<p>When converting files to or from Git LFS, the <code>git lfs migrate</code> command will |
|
only make changes to your local repository and working copy, never any |
|
remotes. This is intentional as the <code>import</code> and <code>export</code> 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" <code>import</code> sub-mode; see [IMPORT (NO REWRITE)] for details.)</p> |
|
|
|
<p>You should therefore always first commit or stash any uncommitted work |
|
before using the <code>import</code> or <code>export</code> modes, and then validate the result of |
|
the migration before pushing the changes to your remotes, for instance by |
|
running the <code>info</code> mode and by examining your rewritten commit history.</p> |
|
|
|
<p>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.</p> |
|
|
|
<p>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 |
|
<code>--include-ref</code> options. They may also be excluded by prefixing them |
|
with <code>^</code> or providing them in <code>--exclude-ref</code> options. Use the <code>--everything</code> |
|
option to specify that all refs should be examined, including all remote refs. |
|
See [INCLUDE AND EXCLUDE (REFS)] for details.</p> |
|
|
|
<p>For the <code>info</code> and <code>import</code> modes, all file types are considered by default; |
|
while useful in the <code>info</code> mode, this is often not desirable when importing, |
|
so either filename patterns (pathspecs) or the <code>--fixup</code> option should |
|
normally be specified in that case. (At least one include pathspec is |
|
required for the <code>export</code> mode.) Pathspecs may be defined using the |
|
<code>--include</code> and <code>--exclude</code> options (<code>-I</code> and <code>-X</code> for short), as described |
|
in <a href="#INCLUDE-AND-EXCLUDE" title="INCLUDE AND EXCLUDE" data-bare-link="true">INCLUDE AND EXCLUDE</a>.</p> |
|
|
|
<p>As typical Git LFS usage depends on tracking specific file types using |
|
filename patterns defined in <code>.gitattributes</code> files, the <code>git lfs migrate</code> |
|
command will examine, create, and modify <code>.gitattributes</code> files as |
|
necessary.</p> |
|
|
|
<p>The <code>import</code> mode (see <a href="#IMPORT" title="IMPORT" data-bare-link="true">IMPORT</a>) will convert Git objects of the file types |
|
specified (e.g., with <code>--include</code>) to Git LFS pointers, and will add entries |
|
for those file types to <code>.gitattributes</code> files, creating those files if they |
|
do not exist. The result should be as if <code>git lfs track</code> 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 <code>--fixup</code> option is |
|
given, in which case the <code>import</code> mode will only examine any existing |
|
<code>.gitattributes</code> files and then convert Git objects which should be tracked |
|
by Git LFS but are not yet.</p> |
|
|
|
<p>The <code>export</code> mode (see <a href="#EXPORT" title="EXPORT" data-bare-link="true">EXPORT</a>) works as the reverse operation to the |
|
<code>import</code> mode, converting any Git LFS pointers that match the file types |
|
specified with <code>--include</code>, which must be given at least once. Note that |
|
<code>.gitattributes</code> entries will not be removed, nor will the files; instead, |
|
the <code>export</code> mode inserts "do not track" entries similar to those created |
|
by the <code>git lfs untrack</code> command. The <code>--remote</code> option is available in |
|
the <code>export</code> 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, <code>origin</code> is used by default.</p> |
|
|
|
<p>The <code>info</code> mode (see <a href="#INFO" title="INFO" data-bare-link="true">INFO</a>) 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 <code>info</code> 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 <code>--everything</code> 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 <code>--pointers=ignore</code> or to treat the pointers as files by using |
|
<code>--pointers=no-follow</code>. (The latter option is akin to how existing Git LFS |
|
pointers were handled by the <code>info</code> mode in prior versions of Git LFS).</p> |
|
|
|
<p>When using the <code>--everything</code> option, take note that it means all refs |
|
(local and remote) will be considered, but not necessarily all file types. |
|
The <code>import</code> and <code>info</code> modes consider all file types by default, although |
|
the <code>--include</code> and <code>--exclude</code> options constrain this behavior. Also |
|
note that after importing across all branches with the <code>--everything</code> option |
|
(and then checking to ensure the results are satisfactory!) it may be |
|
convenient to update multiple branches on your remotes by using the <code>--all</code> |
|
option to <code>git push</code>.</p> |
|
|
|
<p>Unless the <code>--skip-fetch</code> option is given, <code>git lfs migrate</code> always begins by |
|
fetching updated lists of refs from all the remotes returned by <code>git remote</code>, |
|
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.</p> |
|
|
|
<h2 id="MODES">MODES</h2> |
|
|
|
<ul> |
|
<li><p><code>info</code> |
|
Show information about repository size. See <a href="#INFO" title="INFO" data-bare-link="true">INFO</a>.</p></li> |
|
<li><p><code>import</code> |
|
Convert Git objects to Git LFS pointers. See <a href="#IMPORT" title="IMPORT" data-bare-link="true">IMPORT</a> and [IMPORT (NO REWRITE)].</p></li> |
|
<li><p><code>export</code> |
|
Convert Git LFS pointers to Git objects. See <a href="#EXPORT" title="EXPORT" data-bare-link="true">EXPORT</a>.</p></li> |
|
</ul> |
|
|
|
|
|
<h2 id="OPTIONS">OPTIONS</h2> |
|
|
|
<dl> |
|
<dt><code>-I</code> <var>paths</var> <code>--include=</code><var>paths</var></dt><dd><p> See <a href="#INCLUDE-AND-EXCLUDE" title="INCLUDE AND EXCLUDE" data-bare-link="true">INCLUDE AND EXCLUDE</a>.</p></dd> |
|
<dt><code>-X</code> <var>paths</var> <code>--exclude=</code><var>paths</var></dt><dd><p> See <a href="#INCLUDE-AND-EXCLUDE" title="INCLUDE AND EXCLUDE" data-bare-link="true">INCLUDE AND EXCLUDE</a>.</p></dd> |
|
<dt><code>--include-ref</code>=<var>refname</var></dt><dd><p> See [INCLUDE AND EXCLUDE (REFS)].</p></dd> |
|
<dt><code>--exclude-ref</code>=<var>refname</var></dt><dd><p> See [INCLUDE AND EXCLUDE (REFS)].</p></dd> |
|
<dt><code>--skip-fetch</code></dt><dd><p> 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 <code>--include-ref</code> or <code>--exclude-ref</code>.</p></dd> |
|
<dt><code>--everything</code></dt><dd><p> See [INCLUDE AND EXCLUDE (REFS)].</p> |
|
|
|
<p> Note: Git refs are "case-sensitive" on all platforms in "packed from" (see |
|
<code>git-pack-refs(1)</code>). On "case-insensitive" file systems, e.g. NTFS on Windows |
|
or default APFS on macOS, <code>git-lfs-migrate(1)</code> would only migrate the first |
|
ref if two or more refs are equal except for upper/lower case letters.</p></dd> |
|
<dt class="flush"><code>--yes</code></dt><dd><p> 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.</p></dd> |
|
<dt>[branch ...]</dt><dd><p> Migrate only the set of branches listed. If not given, <code>git-lfs-migrate(1)</code> |
|
will migrate the currently checked out branch.</p> |
|
|
|
<p> References beginning with <code>^</code> will be excluded, whereas branches that do not |
|
begin with <code>^</code> will be included.</p> |
|
|
|
<p> If any of <code>--include-ref</code> or <code>--exclude-ref</code> are given, the checked out |
|
branch will not be appended, but branches given explicitly will be appended.</p></dd> |
|
</dl> |
|
|
|
|
|
<h3 id="INFO">INFO</h3> |
|
|
|
<p>The <code>info</code> mode summarizes the sizes of file objects present in the Git history. |
|
It supports all the core <code>migrate</code> options and these additional ones:</p> |
|
|
|
<ul> |
|
<li><p><code>--above=<size></code> |
|
Only count files whose individual filesize is above the given size. <code>size</code> |
|
may be specified as a number of bytes, or a number followed by a storage |
|
unit, e.g., "1b", "20 MB", "3 TiB", etc.</p> |
|
|
|
<p> If a set of files sharing a common extension has no files in that set whose |
|
individual size is above the given <code>--above</code> no files no entry for that set |
|
will be shown.</p></li> |
|
<li><p><code>--top=<n></code> |
|
Only display the top <code>n</code> entries, ordered by how many total files match the |
|
given pathspec. The default is to show only the top 5 entries. When |
|
existing Git LFS objects are found, an extra, separate "LFS Objects" line |
|
is output in addition to the top <code>n</code> entries, unless the <code>--pointers</code> |
|
option is used to change this behavior.</p></li> |
|
<li><p><code>--unit=<unit></code> |
|
Format the number of bytes in each entry as a quantity of the storage unit |
|
provided. Valid units include:</p> |
|
|
|
<pre><code>* b, kib, mib, gib, tib, pib - for IEC storage units |
|
* b, kb, mb, gb, tb, pb - for SI storage units |
|
</code></pre> |
|
|
|
<p> If a <code>--unit</code> is not specified, the largest unit that can fit the number of |
|
counted bytes as a whole number quantity is chosen.</p></li> |
|
<li><p><code>--pointers=[follow|no-follow|ignore]</code> |
|
Treat existing Git LFS pointers in the history according to one of three |
|
alternatives. In the default <code>follow</code> case, if any pointers are found, |
|
an additional separate "LFS Objects" line item is output which summarizes |
|
the total number and size of the Git LFS objects referenced by pointers. |
|
In the <code>ignore</code> case, any pointers are simply ignored, while the <code>no-follow</code> |
|
case replicates the behavior of the <code>info</code> mode in older Git LFS versions |
|
and treats any pointers it finds as if they were regular files, so the |
|
output totals only include the contents of the pointers, not the contents |
|
of the objects to which they refer.</p></li> |
|
<li><p><code>--fixup</code> |
|
Infer <code>--include</code> and <code>--exclude</code> filters on a per-commit basis based on the |
|
.gitattributes files in a repository. In practice, this option counts any |
|
filepaths which should be tracked by Git LFS according to the repository's |
|
.gitattributes file(s), but aren't already pointers. The .gitattributes |
|
files are not reported, in contrast to the normal output of the <code>info</code> mode. |
|
This option is incompatible with explicitly given <code>--include</code>, <code>--exclude</code> |
|
filters and with any <code>--pointers</code> setting other than <code>ignore</code>, hence |
|
<code>--fixup</code> implies <code>--pointers=ignore</code> if it is not explicitly set.</p></li> |
|
</ul> |
|
|
|
|
|
<p>The format of the output shows the filename pattern, the total size of the |
|
file objects (excluding those below the <code>--above</code> 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:</p> |
|
|
|
<pre><code>*.gif 93 MB 9480/10504 files(s) 90% |
|
*.png 14 MB 1732/1877 files(s) 92% |
|
</code></pre> |
|
|
|
<p>By default only the top five entries are shown, but <code>--top</code> allows for |
|
more or fewer to be output as desired.</p> |
|
|
|
<h3 id="IMPORT">IMPORT</h3> |
|
|
|
<p>The <code>import</code> mode migrates objects present in the Git history to pointer |
|
files tracked and stored with Git LFS. It supports all the core <code>migrate</code> |
|
options and these additional ones:</p> |
|
|
|
<ul> |
|
<li><p><code>--verbose</code> |
|
Print the commit oid and filename of migrated files to STDOUT.</p></li> |
|
<li><p><code>--above=<size></code> |
|
Only migrate files whose individual filesize is above the given size. <code>size</code> |
|
may be specified as a number of bytes, or a number followed by a storage |
|
unit, e.g., "1b", "20 MB", "3 TiB", etc.</p></li> |
|
<li><p><code>--object-map=<path></code> |
|
Write to <code>path</code> a file with the mapping of each rewritten commits. The file |
|
format is CSV with this pattern: <code>OLD-SHA</code>,<code>NEW-SHA</code></p></li> |
|
<li><p><code>--no-rewrite</code> |
|
Migrate objects to Git LFS in a new commit without rewriting Git |
|
history. Please note that when this option is used, the <code>migrate import</code> |
|
command will expect a different argument list, specialized options will |
|
become available, and the core <code>migrate</code> options will be ignored. See |
|
[IMPORT (NO REWRITE)].</p></li> |
|
<li><p><code>--fixup</code> |
|
Infer <code>--include</code> and <code>--exclude</code> filters on a per-commit basis based on the |
|
<code>.gitattributes</code> files in a repository. In practice, this option imports any |
|
filepaths which should be tracked by Git LFS according to the repository's |
|
<code>.gitattributes</code> file(s), but aren't already pointers. This option is |
|
incompatible with explicitly given <code>--include</code>, <code>--exclude</code> filters.</p></li> |
|
</ul> |
|
|
|
|
|
<p>If <code>--no-rewrite</code> is not provided and <code>--include</code> or <code>--exclude</code> (<code>-I</code>, <code>-X</code>, |
|
respectively) are given, the <code>.gitattributes</code> will be modified to include any |
|
new filepath patterns as given by those flags.</p> |
|
|
|
<p>If <code>--no-rewrite</code> 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.</p> |
|
|
|
<h3 id="IMPORT-NO-REWRITE-">IMPORT (NO REWRITE)</h3> |
|
|
|
<p>The <code>import</code> mode has a special sub-mode enabled by the <code>--no-rewrite</code> flag. |
|
This sub-mode will migrate objects to pointers as in the base <code>import</code> |
|
mode, but will do so in a new commit without rewriting Git history. When using |
|
this sub-mode, the base <code>migrate</code> options, such as <code>--include-ref</code>, will be |
|
ignored, as will those for the base <code>import</code> mode. The <code>migrate</code> command will |
|
also take a different argument list. As a result of these changes, |
|
<code>--no-rewrite</code> will only operate on the current branch - any other interested |
|
branches must have the generated commit merged in.</p> |
|
|
|
<p>The <code>--no-rewrite</code> sub-mode supports the following options and arguments:</p> |
|
|
|
<ul> |
|
<li><p><code>-m <message> --message=<message></code> |
|
Specifies a commit message for the newly created commit.</p></li> |
|
<li><p>[file ...] |
|
The list of files to import. These files must be tracked by patterns |
|
specified in the gitattributes.</p></li> |
|
</ul> |
|
|
|
|
|
<p>If <code>--message</code> 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.</p> |
|
|
|
<h3 id="EXPORT">EXPORT</h3> |
|
|
|
<p>The <code>export</code> 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 <code>migrate</code> options and these additional ones:</p> |
|
|
|
<ul> |
|
<li><p><code>--verbose</code> |
|
Print the commit oid and filename of migrated files to STDOUT.</p></li> |
|
<li><p><code>--object-map=<path></code> |
|
Write to <code>path</code> a file with the mapping of each rewritten commit. The file |
|
format is CSV with this pattern: <code>OLD-SHA</code>,<code>NEW-SHA</code></p></li> |
|
<li><p><code>--remote=<git-remote></code> |
|
Download LFS objects from the provided <code>git-remote</code> during the export. If |
|
not provided, defaults to <code>origin</code>.</p></li> |
|
</ul> |
|
|
|
|
|
<p>The <code>export</code> mode requires at minimum a pattern provided with the <code>--include</code> |
|
argument to specify which files to export. Files matching the <code>--include</code> |
|
patterns will be removed from Git LFS, while files matching the <code>--exclude</code> |
|
patterns will retain their Git LFS status. The export command will modify the |
|
<code>.gitattributes</code> to set/unset any filepath patterns as given by those flags.</p> |
|
|
|
<h2 id="INCLUDE-AND-EXCLUDE">INCLUDE AND EXCLUDE</h2> |
|
|
|
<p>You can specify that <code>git lfs migrate</code> should only convert files whose |
|
pathspec matches the <code>--include</code> glob patterns and does not match the |
|
<code>--exclude</code> 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.</p> |
|
|
|
<p>Pattern matching is done so as to be functionally equivalent to the pattern |
|
matching format of <code>.gitattributes</code>. In addition to simple file extension |
|
matches (e.g., <code>*.gif</code>) patterns may also specify directory paths, in which |
|
case the <code>path/**</code> format may be used to match recursively.</p> |
|
|
|
<h2 id="INCLUDE-AND-EXCLUDE-REFS-">INCLUDE AND EXCLUDE (REFS)</h2> |
|
|
|
<p>You can specify that <code>git lfs migrate</code> should only convert files added |
|
in commits reachable from certain references, namely those defined using one |
|
or more <code>--include-ref</code> options, and should ignore files in commits reachable |
|
from references defined in <code>--exclude-ref</code> options.</p> |
|
|
|
<pre><code> D---E---F |
|
/ \ |
|
A---B------C refs/heads/my-feature |
|
\ \ |
|
\ refs/heads/main |
|
\ |
|
refs/remotes/origin/main |
|
</code></pre> |
|
|
|
<p>In the above configuration, the following commits are reachable by each ref:</p> |
|
|
|
<pre><code>refs/heads/main: C, B, A |
|
refs/heads/my-feature: F, E, D, B, A |
|
refs/remote/origin/main: A |
|
</code></pre> |
|
|
|
<p>The following <code>git lfs migrate</code> options would, therefore, include commits |
|
F, E, D, C, and B, but exclude commit A:</p> |
|
|
|
<pre><code> --include-ref=refs/heads/my-feature |
|
--include-ref=refs/heads/main |
|
--exclude-ref=refs/remotes/origin/main |
|
</code></pre> |
|
|
|
<p>The presence of flag <code>--everything</code> indicates that all local and remote |
|
references should be migrated.</p> |
|
|
|
<h2 id="EXAMPLES">EXAMPLES</h2> |
|
|
|
<h3 id="Migrate-unpushed-commits">Migrate unpushed commits</h3> |
|
|
|
<p>A 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.</p> |
|
|
|
<p>First, run <code>git lfs migrate info</code> to list the file types taking up the most |
|
space in your repository:</p> |
|
|
|
<pre><code>$ 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% |
|
</code></pre> |
|
|
|
<p>Now, you can run <code>git lfs migrate import</code> to convert some file types to LFS:</p> |
|
|
|
<pre><code>$ git lfs migrate import --include="*.mp3,*.psd" |
|
migrate: Fetching remote refs: ..., done |
|
migrate: Sorting commits: ..., done |
|
migrate: Rewriting commits: 100% (1/1), done |
|
main d2b959babd099fe70da1c1512e2475e8a24de163 -> 136e706bf1ae79643915c134e17a6c933fd53c61 |
|
migrate: Updating refs: ..., done |
|
</code></pre> |
|
|
|
<p>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 |
|
<code>git lfs checkout</code>.</p> |
|
|
|
<h3 id="Migrate-local-history">Migrate local history</h3> |
|
|
|
<p>You can also migrate the entire history of your repository:</p> |
|
|
|
<pre><code># Check for large files and existing Git LFS objects in your local main branch |
|
$ git lfs migrate info --include-ref=main |
|
|
|
# Check for large files and existing Git LFS objects in every branch |
|
$ git lfs migrate info --everything |
|
|
|
# Check for large files in every branch, ignoring any existing Git LFS objects, |
|
# and listing the top 100 or fewer results |
|
$ git lfs migrate info --everything --pointers=ignore --top=100 |
|
</code></pre> |
|
|
|
<p>The same flags will work in <code>import</code> mode:</p> |
|
|
|
<pre><code># Convert all zip files in your main branch |
|
$ git lfs migrate import --include-ref=main --include="*.zip" |
|
|
|
# Convert all zip files in every local branch |
|
$ git lfs migrate import --everything --include="*.zip" |
|
|
|
# Convert all files over 100K in every local branch |
|
$ git lfs migrate import --everything --above=100Kb |
|
</code></pre> |
|
|
|
<p>Note: This will require a force-push to any existing Git remotes. Using |
|
the <code>--all</code> option when force-pushing may be convenient if many refs were |
|
updated, e.g., after importing to Git LFS with the <code>--everything</code> option.</p> |
|
|
|
<h3 id="Migrate-without-rewriting-local-history">Migrate without rewriting local history</h3> |
|
|
|
<p>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> |
|
|
|
<p>Without a specified commit message:</p> |
|
|
|
<pre><code>$ git lfs migrate import --no-rewrite test.zip *.mp3 *.psd |
|
</code></pre> |
|
|
|
<p>With a specified commit message:</p> |
|
|
|
<pre><code>$ git lfs migrate import --no-rewrite \ |
|
-m "Import test.zip, .mp3, .psd files in root of repo" \ |
|
test.zip *.mp3 *.psd |
|
</code></pre> |
|
|
|
<h2 id="SEE-ALSO">SEE ALSO</h2> |
|
|
|
<p><span class="man-ref">git-lfs-checkout<span class="s">(1)</span></span>, <span class="man-ref">git-lfs-track<span class="s">(1)</span></span>, <span class="man-ref">git-lfs-untrack<span class="s">(1)</span></span>, <span class="man-ref">gitattributes<span class="s">(5)</span></span>.</p> |
|
|
|
<p>Part of the <span class="man-ref">git-lfs<span class="s">(1)</span></span> suite.</p> |
|
|
|
|
|
<ol class='man-decor man-foot man foot'> |
|
<li class='tl'></li> |
|
<li class='tc'>October 2021</li> |
|
<li class='tr'>git-lfs-migrate(1)</li> |
|
</ol> |
|
|
|
</div> |
|
</body> |
|
</html> |
|
|