| 1 |
= git-lfs-merge-driver(1) |
| 2 |
|
| 3 |
== NAME |
| 4 |
|
| 5 |
git-lfs-merge-driver - Merge text-based LFS files |
| 6 |
|
| 7 |
== SYNOPSIS |
| 8 |
|
| 9 |
[source,role=synopsis,subs="verbatim,quotes"] |
| 10 |
---- |
| 11 |
*git lfs merge-driver* [_options_] |
| 12 |
---- |
| 13 |
|
| 14 |
== DESCRIPTION |
| 15 |
|
| 16 |
Merge text files stored in Git LFS using the default Git merge |
| 17 |
machinery, or a custom merge driver if specified. Note that this, in |
| 18 |
general, does not support partial renames or copies because Git does not |
| 19 |
support them in this case. |
| 20 |
|
| 21 |
This program is intended to be invoked automatically by Git and not by |
| 22 |
users manually. See <<_configuration>> for details on the configuration |
| 23 |
required for that. |
| 24 |
|
| 25 |
== OPTIONS |
| 26 |
|
| 27 |
`--ancestor <path>`:: |
| 28 |
Specify the file containing the ancestor revision. |
| 29 |
`--current <path>`:: |
| 30 |
Specify the file containing the current revision. |
| 31 |
`--marker-size <num>`:: |
| 32 |
Specify the conflict marker size as an integer. |
| 33 |
`--other <path>`:: |
| 34 |
Specify the file containing the other revision. |
| 35 |
`--output`:: |
| 36 |
Specify the file into which the merged output will be written. |
| 37 |
`--program <program>`:: |
| 38 |
Specify a command, which is passed to the shell after substitution, that |
| 39 |
performs the actual merge. If this is not specified, `git merge-file` is |
| 40 |
invoked with appropriate arguments to perform the merge of the file. |
| 41 |
+ |
| 42 |
See <<_configuration>> for the sequences which are substituted here. |
| 43 |
|
| 44 |
== CONFIGURATION |
| 45 |
|
| 46 |
Git allows the use of a custom merge driver for files based on the |
| 47 |
`merge` attribute set in `.gitattributes`. By default, when using |
| 48 |
`git lfs track`, this value is set to `lfs`. |
| 49 |
|
| 50 |
Because Git LFS can be used to store both text and binary files and it |
| 51 |
isn't always clear which behavior should be used, Git LFS does not |
| 52 |
enable this merge driver by default. However, if you know that some or |
| 53 |
all of your files are text files, then you can set the `merge` attribute |
| 54 |
for those files to `lfs-text` and use `git config` to set the merge |
| 55 |
driver like so: |
| 56 |
|
| 57 |
[source,console] |
| 58 |
---- |
| 59 |
$ git config merge.lfs-text.driver 'git lfs merge-driver --ancestor %O --current %A --other %B --marker-size %L --output %A' |
| 60 |
---- |
| 61 |
|
| 62 |
This tells Git to invoke the custom Git LFS merge driver, which in turn |
| 63 |
uses Git's merge machinery, to merge files where the `merge` attribute |
| 64 |
is set to `lfs-text`. Note that `lfs-text` here is an example and any |
| 65 |
syntactically valid value can be used. |
| 66 |
|
| 67 |
If you are using a special type of file that needs rules different from |
| 68 |
Git's standard merge machinery, you can also specify the `--program` |
| 69 |
option, which is passed to `sh` after substituting its own |
| 70 |
percent-encoded escapes: |
| 71 |
|
| 72 |
* `%A`: the current version |
| 73 |
* `%B`: the other version |
| 74 |
* `%D`: the destination (i.e., output) version |
| 75 |
* `%O`: the ancestor version |
| 76 |
* `%L`: the conflict marker size |
| 77 |
|
| 78 |
Note that the percent sign must typically be doubled to prevent Git from |
| 79 |
substituting its own values here. Therefore, specifying the default |
| 80 |
behavior explicitly looks like this: |
| 81 |
|
| 82 |
[source,console] |
| 83 |
---- |
| 84 |
$ git config merge.lfs-text.driver \ |
| 85 |
'git lfs merge-driver --ancestor %O --current %A --other %B --marker-size %L --output %A --program '\''git merge-file --stdout --marker-size=%%L %%A %%O %%B >%%D'\''' |
| 86 |
---- |
| 87 |
|
| 88 |
The exit status from the custom command should be zero on success or |
| 89 |
non-zero on conflicts or other failure. |
| 90 |
|
| 91 |
Note that if no merge driver is specified for the value of the `merge` |
| 92 |
attribute (as is the case by default with `merge=lfs`), then the default |
| 93 |
Git merge strategy is used. For LFS files, this means that Git will try |
| 94 |
to merge the pointer files, which usually is not useful. |
| 95 |
|
| 96 |
== SEE ALSO |
| 97 |
|
| 98 |
git-merge(1), git-merge-file(1), gitattributes(5) |
| 99 |
|
| 100 |
Part of the git-lfs(1) suite. |