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