diff options
Diffstat (limited to 'doc/user/project/git_attributes.md')
-rw-r--r-- | doc/user/project/git_attributes.md | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/doc/user/project/git_attributes.md b/doc/user/project/git_attributes.md index 5e67706708d..61e73fcce81 100644 --- a/doc/user/project/git_attributes.md +++ b/doc/user/project/git_attributes.md @@ -1,8 +1,7 @@ --- stage: Create group: Source Code -info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments" -type: reference +info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments" --- # Git attributes **(FREE ALL)** @@ -52,3 +51,72 @@ For more information, see [working-tree-encoding](https://git-scm.com/docs/gitat The `.gitattributes` file can be used to define which language to use when syntax highlighting files and diffs. For more information, see [Syntax highlighting](highlighting.md). + +## Custom merge drivers **(FREE SELF)** + +> Ability to configure custom merge drivers through GitLab introduced in GitLab 15.10. + +GitLab self-managed instance administrators can define [custom merge drivers](https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver) +in a GitLab configuration file, then use the custom merge drivers in a Git `.gitattributes` file. Custom merge drivers are not supported on GitLab.com. + +You might configure a custom merge driver, for example, if there are certain +files that should be ignored during a merge such as build files and configuration files. + +### Configure a custom merge driver + +The following example illustrates how to define and use a custom merge driver in +GitLab. + +How to configure a custom merge driver depends on the type of installation. + +::Tabs + +:::TabTitle Linux package (Omnibus) + +1. Edit `/etc/gitlab/gitlab.rb`. +1. Add configuration similar to the following: + + ```ruby + gitaly['configuration'] = { + # ... + git: { + # ... + config: [ + # ... + { key: "merge.foo.driver", value: "true" }, + ], + }, + } + ``` + +:::TabTitle Self-compiled (source) + +1. Edit `gitaly.toml`. +1. Add configuration similar to the following: + + ```toml + [[git.config]] + key = "merge.foo.driver" + value = "true" + ``` + +::EndTabs + +In this example, during a merge, Git uses the `driver` value as the command to execute. In +this case, because we are using [`true`](https://man7.org/linux/man-pages/man1/true.1.html) +with no arguments, it always returns a non-zero return code. This means that for +the files specified in `.gitattributes`, merges do nothing. + +To use your own merge driver, replace the value in `driver` to point to an +executable. For more details on how this command is invoked, see the Git +documentation on [custom merge drivers](https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver). + +### Use `.gitattributes` to set files custom merge driver applies to + +In a `.gitattributes` file, you can set the paths of files you want to use with the custom merge driver. For example: + +```plaintext +config/* merge=foo +``` + +In this case, every file under the `config/` folder uses the custom merge driver called `foo` defined in the GitLab configuration. |