| 1 |
= git-lfs-checkout(1) |
| 2 |
|
| 3 |
== NAME |
| 4 |
|
| 5 |
git-lfs-checkout - Update working copy with file content if available |
| 6 |
|
| 7 |
== SYNOPSIS |
| 8 |
|
| 9 |
[source,role=synopsis,subs="verbatim,quotes"] |
| 10 |
---- |
| 11 |
*git lfs checkout* [_<glob-pattern>_...] |
| 12 |
*git lfs checkout --to* _<file>_ {*--base*|*--ours*|*--theirs*} _<conflict-obj-path>_ |
| 13 |
---- |
| 14 |
|
| 15 |
== DESCRIPTION |
| 16 |
|
| 17 |
Try to ensure that the working copy contains file content for Git LFS |
| 18 |
objects for the current ref, if the object data is available. Does not |
| 19 |
download any content; see git-lfs-fetch(1) for that. |
| 20 |
|
| 21 |
Checkout scans the current ref for all LFS objects that would be |
| 22 |
required, then where a file is either missing in the working copy, or |
| 23 |
contains placeholder pointer content with the same SHA, the real file |
| 24 |
content is written, provided we have it in the local store. Modified |
| 25 |
files are never overwritten. |
| 26 |
|
| 27 |
One or more `<glob-pattern>` arguments may be provided to restrict the set of files |
| 28 |
that are updated. Glob patterns are matched as per the format described |
| 29 |
in gitignore(5). |
| 30 |
|
| 31 |
When used with `--to` and the working tree is in a conflicted state due |
| 32 |
to a merge, this option checks out one of the three stages a conflicting |
| 33 |
Git LFS object into a separate file (which can be outside of the work |
| 34 |
tree). This can make using diff tools to inspect and resolve merges |
| 35 |
easier. A single Git LFS object's file path must be provided in |
| 36 |
`<conflict-obj-path>`. If `<file>` already exists, whether as a regular |
| 37 |
file, symbolic link, or directory, it will be removed and replaced, unless |
| 38 |
it is a non-empty directory or otherwise cannot be deleted. |
| 39 |
|
| 40 |
If the installed Git version is at least 2.42.0, |
| 41 |
this command will by default check out Git LFS objects for files |
| 42 |
only if they are present in the Git index and if they match a Git LFS |
| 43 |
filter attribute from a `.gitattributes` file that is present in either |
| 44 |
the index or the current working tree (or, as is always the case, if |
| 45 |
they match a Git LFS filter attribute in a local `gitattributes` file |
| 46 |
such as `$GIT_DIR/info/attributes`). These constraints do not apply |
| 47 |
with prior versions of Git. |
| 48 |
|
| 49 |
In a repository with a partial clone or sparse checkout, it is therefore |
| 50 |
advisable to check out all `.gitattributes` files from `HEAD` before |
| 51 |
using this command, if Git v2.42.0 or later is installed. Alternatively, |
| 52 |
the `GIT_ATTR_SOURCE` environment variable may be set to `HEAD`, which |
| 53 |
will cause Git to only read attributes from `.gitattributes` files in |
| 54 |
`HEAD` and ignore those in the index or working tree. |
| 55 |
|
| 56 |
In a bare repository, this command has no effect. In a future version, |
| 57 |
this command may exit with an error if it is run in a bare repository. |
| 58 |
|
| 59 |
== OPTIONS |
| 60 |
|
| 61 |
`--base`:: |
| 62 |
Check out the merge base of the specified file. |
| 63 |
`--ours`:: |
| 64 |
Check out our side (that of the current branch) of the |
| 65 |
conflict for the specified file. |
| 66 |
`--theirs`:: |
| 67 |
Check out their side (that of the other branch) of the |
| 68 |
conflict for the specified file. |
| 69 |
`--to <path>`:: |
| 70 |
If the working tree is in a conflicted state, check out the |
| 71 |
portion of the conflict specified by `--base`, `--ours`, or `--theirs` |
| 72 |
to the given path. |
| 73 |
|
| 74 |
== EXAMPLES |
| 75 |
|
| 76 |
* Checkout all files that are missing or placeholders: |
| 77 |
|
| 78 |
.... |
| 79 |
$ git lfs checkout |
| 80 |
.... |
| 81 |
|
| 82 |
* Checkout a specific couple of files: |
| 83 |
|
| 84 |
.... |
| 85 |
$ git lfs checkout path/to/file1.png path/to.file2.png |
| 86 |
.... |
| 87 |
|
| 88 |
* Checkout a path with a merge conflict into separate files: |
| 89 |
|
| 90 |
.... |
| 91 |
# Attempt merge with a branch that has a merge conflict |
| 92 |
$ git merge conflicting-branch |
| 93 |
CONFLICT (content): Merge conflict in path/to/conflicting/file.dat |
| 94 |
|
| 95 |
# Checkout versions of the conflicting file into temp files |
| 96 |
$ git lfs checkout --to ours.dat --ours path/to/conflicting/file.dat |
| 97 |
$ git lfs checkout --to theirs.dat --theirs path/to/conflicting/file.dat |
| 98 |
|
| 99 |
# Compare conflicting versions in ours.dat and theirs.dat, |
| 100 |
# then resolve conflict (e.g., by choosing one version over |
| 101 |
# the other, or creating a new version) |
| 102 |
|
| 103 |
# Cleanup and continue with merge |
| 104 |
$ rm ours.dat theirs.dat |
| 105 |
$ git add path/to/conflicting/file.dat |
| 106 |
$ git merge --continue |
| 107 |
.... |
| 108 |
|
| 109 |
== SEE ALSO |
| 110 |
|
| 111 |
git-lfs-fetch(1), git-lfs-pull(1), gitattributes(5), gitignore(5). |
| 112 |
|
| 113 |
Part of the git-lfs(1) suite. |