Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:28:13+00:00 2026-05-28T08:28:13+00:00

I’m creating a merge driver. I have defined a .gitattributes file as follows: filename

  • 0

I’m creating a merge driver. I have defined a .gitattributes file as follows:

filename merge=mergeStrategy

I have created the merge driver in $PROJECT/.git/config as follows:

[merge "mergeStrategy"]
    name = My merge strategy
    driver = scripts/mergeScript.sh

This works fine locally, but I would like to commit this merge driver to the git repository so that the merge strategy is in effect for everyone.

Is there a way I can add this (or other Git configuration options) to the repository itself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:28:14+00:00Added an answer on May 28, 2026 at 8:28 am

    You could simply add and commit (and push) script/mergeScript (along with the .gitattributes file, of course)

    That would work as long as:

    • mergeScript is somehow in the $PATH of the user executing the merge driver.
    • mergeScript is executable, chmod +x
    • mergeScript is without extension, to allow you to later change its content (from a bash shell to a Perl script to a C executable to …) if needed.

    (Thank you, MestreLion, for the last two points, as he mentioned them in the comment)

    That was the case for you locally, as I suspect that ‘.‘ was in your $PATH, but you cannot assume that for everybody.

    However, the local config file (.git/config) won’t be pushed/cloned (as Alexandr Priymak points out in the comment), so the users still need to replicate the declaration of the custom merge driver.

    This is a basic safety measure, in order for you to not push a potential "harmful" script which would then be automatically executed at the next merge.

    An alternative method using Makefile

    An another option is to keep all the git drivers and .gitattributes in the version history and also include something that easily activates all the drivers. For example, one project used Makefile that had special target make gitdrivers that activated all the git drivers in the repo.

    This is needed because git considers custom drivers as potential security vulnerability and you need to do something to grant trust to any new drivers. The merge drivers and other hooks are executable code running on your user credentials that start automatically as a side-effect on git actions, so obviously extra care must be taken before running that code.

    Running code that changes .git/config to activate the drivers is the git style of granting the trust.

    In practice, you can use Makefile for that (but you could use whatever build system or script that suits your project). For Ubuntu Linux hosts, you can simply do it like follows (example with three drivers):

    In file .gitattributes:

    [attr]POFILE merge=merge-po-files
    [attr]IMAGE diff=image
    [attr]BINARY diff=binary -merge -text
    
    locale/*.po POFILE
    data/*.img BINARY
    *.png IMAGE
    

    and in Makefile (indent should be done with U+0009 TAB character only but stackoverflow.com doesn’t support it here):

    developer-dependencies:
            sudo apt install required-package1 required-package2
    
    submodules:
            @echo "Overwriting submodules with committed versions..."
            git submodule sync
            git submodule update --init
    
    gitdrivers: developer-dependencies submodules
            @echo "Overwriting git drivers with current version..."
            git config merge.merge-po-files.driver "./bin/merge-po-files %A %O %B"
            # show rough thumbnails in text mode for images
            git config diff.image.textconv "./bin/image-textconv"
            git config diff.image.binary "true"
            git config diff.image.cachetextconv "true"
            # show some extra information about binary files
            git config diff.binary.textconv "./bin/binary-textconv"
            git config diff.binary.binary "true"
            @echo "All git drivers done."
    

    Where files merge-po-files, image-textconv and binary-textconv are suitable executables in the project subdirectory bin. If you have a project that needs to work on multiple platforms, you could have an extra dependency to build/link correct binary for the current platform.

    The example config tells git to render ASCII presentation of images in diffs, merge gettext .PO files with special merge driver and prevent merging selected binary files even if git heuristics declare those as text. Instead require selecting one version or the other for files marked as BINARY. And show special user visible summary for the BINARY files in diffs.

    This way all developers just need to run make gitdrivers once after doing the initial clone. And they automatically get updates to drivers that they’ve already installed when they merge or rebase their working copy later. And if they’re not sure if they have the latest drivers, they can simply re-run the same command at any time. Note that the example above will reset all submodules you have which may or may not what you really want.

    TL;DR: .git/config is not included in the repository but you can include a script that re-creates suitable config using git config commands. For UNIX-like systems a shell script is great. If your project needs building the code you can hook installing the required drivers to build process if needed. Also note that it’s much safer to use git config ... commands instead of trying to directly modify the config file because those commands will keep working even if the file format of that config file changed in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.