github.com/x-oss-byte/git-lfs@v2.5.2+incompatible/docs/man/git-lfs-migrate.1.ronn (about) 1 git-lfs-migrate(1) - Migrate history to or from git-lfs 2 ======================================================= 3 4 ## SYNOPSIS 5 6 `git lfs migrate` <mode> [options] [--] [branch ...] 7 8 ## MODES 9 10 * `info` 11 Show information about repository size. 12 13 * `import` 14 Convert large Git objects to LFS pointers. 15 16 ## OPTIONS 17 18 * `-I` <paths> `--include=`<paths>: 19 See [INCLUDE AND EXCLUDE]. 20 21 * `-X` <paths> `--exclude=`<paths>: 22 See [INCLUDE AND EXCLUDE]. 23 24 * `--include-ref`=<refname>: 25 See [INCLUDE AND EXCLUDE (REFS)]. 26 27 * `--exclude-ref`=<refname>: 28 See [INCLUDE AND EXCLUDE (REFS)]. 29 30 * `--skip-fetch`: 31 Assumes that the known set of remote references is complete, and should not 32 be refreshed when determining the set of "un-pushed" commits to migrate. Has 33 no effect when combined with `--include-ref` or `--exclude-ref`. 34 35 * `--everything`: 36 See [INCLUDE AND EXCLUDE (REFS)]. 37 38 * [branch ...]: 39 Migrate only the set of branches listed. If not given, `git-lfs-migrate(1)` 40 will migrate the currently checked out branch. 41 42 References beginning with '^' will be excluded, whereas branches that do not 43 begin with '^' will be included. 44 45 If any of `--include-ref` or `--exclude-ref` are given, the checked out 46 branch will not be appended, but branches given explicitly will be appended. 47 48 ### INFO 49 50 The 'info' mode has these additional options: 51 52 * `--above=<size>` 53 Only count files whose individual filesize is above the given size. 'size' 54 may be specified as a number of bytes, or a number followed by a storage 55 unit, e.g., "1b", "20 MB", "3 TiB", etc. 56 57 If a set of files sharing a common extension has no files in that set whose 58 individual size is above the given `--above` no files no entry for that set 59 will be shown. 60 61 * `--top=<n>` 62 Only include the top 'n' entries, ordered by how many total files match the 63 given pathspec. 64 65 * `--unit=<unit>` 66 Format the number of bytes in each entry as a quantity of the storage unit 67 provided. Valid units include: 68 * b, kib, mib, gib, tib, pib - for IEC storage units 69 * b, kb, mb, gb, tb, pb - for SI storage units 70 71 If a --unit is not specified, the largest unit that can fit the number of 72 counted bytes as a whole number quantity is chosen. 73 74 ### IMPORT 75 76 The 'import' mode migrates large objects present in the Git history to pointer 77 files tracked and stored with Git LFS. It supports all the core 'migrate' 78 options and these additional ones: 79 80 * `--verbose` 81 Print the commit oid and filename of migrated files to STDOUT. 82 83 * `--object-map=<path>` 84 Write to 'path' a file with the mapping of each rewritten commits. The file 85 format is CSV with this pattern: `OLD-SHA`,`NEW-SHA` 86 87 * `--no-rewrite` 88 Migrate large objects to Git LFS in a new commit without rewriting git 89 history. Please note that when this option is used, the `migrate import` 90 command will expect a different argument list, specialized options will 91 become available, and the core `migrate` options will be ignored. See 92 [IMPORT (NO REWRITE)]. 93 94 * `--fixup` 95 Infer `--include` and `--exclude` filters on a per-commit basis based on the 96 .gitattributes files in a repository. In practice, this option imports any 97 filepaths which should be tracked by Git LFS according to the repository's 98 .gitattributes file(s), but aren't already pointers. This option is 99 incompatible with explicitly given `--include`, `--exclude` filters. 100 101 If `--no-rewrite` is not provided and `--include` or `--exclude` (`-I`, `-X`, 102 respectively) are given, the .gitattributes will be modified to include any new 103 filepath patterns as given by those flags. 104 105 If `--no-rewrite` is not provided and neither of those flags are given, the 106 gitattributes will be incrementally modified to include new filepath extensions 107 as they are rewritten in history. 108 109 ### IMPORT (NO REWRITE) 110 111 The `import` mode has a special sub-mode enabled by the `--no-rewrite` flag. 112 This sub-mode will migrate large objects to pointers as in the base `import` 113 mode, but will do so in a new commit without rewriting Git history. When using 114 this sub-mode, the base `migrate` options, such as `--include-ref`, will be 115 ignored, as will those for the base `import` mode. The `migrate` command will 116 also take a different argument list. As a result of these changes, 117 `--no-rewrite` will only operate on the current branch - any other interested 118 branches must have the generated commit merged in. 119 120 The `--no-rewrite` sub-mode supports the following options and arguments: 121 122 * `-m <message> --message=<message>` 123 Specifies a commit message for the newly created commit. 124 125 * [file ...] 126 The list of files to import. These files must be tracked by patterns 127 specified in the gitattributes. 128 129 If `--message` is given, the new commit will be created with the provided 130 message. If no message is given, a commit message will be generated based on the 131 file arguments. 132 133 ### EXPORT 134 135 The 'export' mode migrates Git LFS pointer files present in the Git history out 136 of Git LFS, converting them into their corresponding object files. It supports 137 all the core 'migrate' options and these additional ones: 138 139 * `--verbose` 140 Print the commit oid and filename of migrated files to STDOUT. 141 142 * `--object-map=<path>` 143 Write to 'path' a file with the mapping of each rewritten commit. The file 144 format is CSV with this pattern: `OLD-SHA`,`NEW-SHA` 145 146 * `--remote=<git-remote>` 147 Download LFS objects from the provided 'git-remote' during the export. If 148 not provided, defaults to 'origin'. 149 150 The 'export' mode requires at minimum a pattern provided with the `--include` 151 argument to specify which files to export. Files matching the `--include` 152 patterns will be removed from Git LFS, while files matching the `--exclude` 153 patterns will retain their Git LFS status. The export command will modify the 154 .gitattributes to set/unset any filepath patterns as given by those flags. 155 156 ## INCLUDE AND EXCLUDE 157 158 You can configure Git LFS to only migrate tree entries whose pathspec matches 159 the include glob and does not match the exclude glob, to reduce total migration 160 time or to only migrate part of your repo. Specify multiple patterns using the 161 comma as the delimiter. 162 163 Pattern matching is done as given to be functionally equivalent to pattern 164 matching as in .gitattributes. 165 166 ## INCLUDE AND EXCLUDE (REFS) 167 168 You can configure Git LFS to only migrate commits reachable by references 169 include by `--include-ref` and not reachable by `--exclude-ref`. 170 171 D---E---F 172 / \ 173 A---B------C refs/heads/my-feature 174 \ \ 175 \ refs/heads/master 176 \ 177 refs/remotes/origin/master 178 179 In the above configuration, the following commits are reachable by each ref: 180 181 refs/heads/master: C, B, A 182 refs/heads/my-feature: F, E, D, B, A 183 refs/remote/origin/master: A 184 185 The following configuration: 186 187 --include-ref=refs/heads/my-feature 188 --include-ref=refs/heads/master 189 --exclude-ref=refs/remotes/origin/master 190 191 Would, therefore, include commits: F, E, D, C, B, but exclude commit A. 192 193 The presence of flag `--everything` indicates that all local and remote 194 references should be migrated. 195 196 ## EXAMPLES 197 198 ### Migrate unpushed commits 199 200 The migrate command's most common use case is to convert large git objects to 201 LFS before pushing your commits. By default, it only scans commits that don't 202 exist on any remote, so long as the repository is non-bare. 203 204 First, run `git lfs migrate info` to list the file types taking up the most 205 space in your repository. 206 207 ``` 208 $ git lfs migrate info 209 migrate: Fetching remote refs: ..., done 210 migrate: Sorting commits: ..., done 211 migrate: Examining commits: 100% (1/1), done 212 *.mp3 284 MB 1/1 files(s) 100% 213 *.pdf 42 MB 8/8 files(s) 100% 214 *.psd 9.8 MB 15/15 files(s) 100% 215 *.ipynb 6.9 MB 6/6 files(s) 100% 216 *.csv 5.8 MB 2/2 files(s) 100% 217 ``` 218 219 Now, you can run `git lfs migrate import` to convert some file types to LFS: 220 221 ``` 222 $ git lfs migrate import --include="*.mp3,*.psd" 223 migrate: Fetching remote refs: ..., done 224 migrate: Sorting commits: ..., done 225 migrate: Rewriting commits: 100% (1/1), done 226 master d2b959babd099fe70da1c1512e2475e8a24de163 -> 136e706bf1ae79643915c134e17a6c933fd53c61 227 migrate: Updating refs: ..., done 228 ``` 229 230 ### Migrate local history 231 232 You can also migrate the entire history of your repository: 233 234 ``` 235 # Check for large files in your local master branch 236 $ git lfs migrate info --include-ref=master 237 238 # Check for large files in every branch 239 $ git lfs migrate info --everything 240 ``` 241 242 The same flags will work in `import` mode: 243 244 ``` 245 # Convert all zip files in your master branch 246 $ git lfs migrate import --include-ref=master --include="*.zip" 247 248 # Convert all zip files in every local branch 249 $ git lfs migrate import --everything --include="*.zip" 250 ``` 251 252 Note: This will require a force push to any existing Git remotes. 253 254 ### Migrate without rewriting local history 255 256 You can also migrate files without modifying the existing history of your 257 repository: 258 259 Without a specified commit message: 260 261 ``` 262 $ git lfs migrate import --no-rewrite test.zip *.mp3 *.psd 263 ``` 264 265 With a specified commit message: 266 267 ``` 268 $ git lfs migrate import --no-rewrite -m "Import .zip, .mp3, .psd files" \ 269 test.zip *.mpd *.psd 270 ``` 271 272 ## SEE ALSO 273 274 Part of the git-lfs(1) suite.