File size: 26,706 Bytes
353e225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<!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'>
  /* style: man */
  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>
<!--
  The following styles are deprecated and will be removed at some point:
  div#man, div#man ol.man, div#man ol.head, div#man ol.man.

  The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
  .man-navigation should be used instead.
-->
<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=&lt;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=&lt;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=&lt;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=&lt;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=&lt;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 &lt;message> --message=&lt;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=&lt;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=&lt;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 -&gt; 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>