Home Explore Blog CI



git

15th chunk of `Documentation/gitattributes.adoc`
d26c9c602e731eef496913d5213fd9ee20079399f973f9950000000100000fa0
 the work tree, but
	leave the path in the conflicted state for the user to
	sort out.

union::

	Run 3-way file level merge for text files, but take
	lines from both versions, instead of leaving conflict
	markers.  This tends to leave the added lines in the
	resulting file in random order and the user should
	verify the result. Do not use this if you do not
	understand the implications.


Defining a custom merge driver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The definition of a merge driver is done in the `.git/config`
file, not in the `gitattributes` file, so strictly speaking this
manual page is a wrong place to talk about it.  However...

To define a custom merge driver `filfre`, add a section to your
`$GIT_DIR/config` file (or `$HOME/.gitconfig` file) like this:

----------------------------------------------------------------
[merge "filfre"]
	name = feel-free merge driver
	driver = filfre %O %A %B %L %P
	recursive = binary
----------------------------------------------------------------

The `merge.*.name` variable gives the driver a human-readable
name.

The `merge.*.driver` variable's value is used to construct a
command to run to common ancestor's version (`%O`), current
version (`%A`) and the other branches' version (`%B`).  These
three tokens are replaced with the names of temporary files that
hold the contents of these versions when the command line is
built. Additionally, `%L` will be replaced with the conflict marker
size (see below).

The merge driver is expected to leave the result of the merge in
the file named with `%A` by overwriting it, and exit with zero
status if it managed to merge them cleanly, or non-zero if there
were conflicts.  When the driver crashes (e.g. killed by SEGV),
it is expected to exit with non-zero status that are higher than
128, and in such a case, the merge results in a failure (which is
different from producing a conflict).

The `merge.*.recursive` variable specifies what other merge
driver to use when the merge driver is called for an internal
merge between common ancestors, when there are more than one.
When left unspecified, the driver itself is used for both
internal merge and the final merge.

The merge driver can learn the pathname in which the merged result
will be stored via placeholder `%P`. The conflict labels to be used
for the common ancestor, local head and other head can be passed by
using `%S`, `%X` and `%Y` respectively.

`conflict-marker-size`
^^^^^^^^^^^^^^^^^^^^^^

This attribute controls the length of conflict markers left in
the work tree file during a conflicted merge.  Only a positive
integer has a meaningful effect.

For example, this line in `.gitattributes` can be used to tell the merge
machinery to leave much longer (instead of the usual 7-character-long)
conflict markers when merging the file `Documentation/git-merge.adoc`
results in a conflict.

------------------------
Documentation/git-merge.adoc	conflict-marker-size=32
------------------------


Checking whitespace errors
~~~~~~~~~~~~~~~~~~~~~~~~~~

`whitespace`
^^^^^^^^^^^^

The `core.whitespace` configuration variable allows you to define what
'diff' and 'apply' should consider whitespace errors for all paths in
the project (See linkgit:git-config[1]).  This attribute gives you finer
control per path.

Set::

	Notice all types of potential whitespace errors known to Git.
	The tab width is taken from the value of the `core.whitespace`
	configuration variable.

Unset::

	Do not notice anything as error.

Unspecified::

	Use the value of the `core.whitespace` configuration variable to
	decide what to notice as error.

String::

	Specify a comma separated list of common whitespace problems to
	notice in the same format as the `core.whitespace` configuration
	variable.


Creating an archive
~~~~~~~~~~~~~~~~~~~

`export-ignore`
^^^^^^^^^^^^^^^

Files and directories with the attribute `export-ignore` won't be added to
archive files.

`export-subst`
^^^^^^^^^^^^^^

If the attribute `export-subst` is set for a file

Title: Customizing Git Merge Drivers and Attributes
Summary
Git allows customization of merge drivers and attributes, including defining custom merge drivers, specifying conflict marker sizes, and controlling whitespace errors, to fine-tune the merge and diff process for specific files and projects.