gitgithubgitattributes

On github, is there a way to force the user to merge when specific files have changed


I've developed a git merge driver - basically a specialized json merge. I want to have certain file merges to fail, causing the user to merge. All of this works fine on developer machines but github pull requests allow squash merges.

I made a number of changes to .gitattributes, including unsetting the merge attrib and trying to make it look like binary:

**/mypath/*.json -merge

**/mypath/*.json -text

My preference is something like this:

**/mypath/*.json merge=AutoMergeDriver -text

I expected the merge driver to be ignored by github and the merge by github would not be allowed because it would be considered binary (by -text). And developer systems would use the driver (defined in each developers' git config). I'd still like github to be able to show diffs on the file (it currently does) - while not always valid, most of the time a github text diff would be valuable for reviewers.


Solution

  • To prevent GitHub from automatically merging the files, mark them as binary:

    **/mypath/*.json binary
    

    binary is a Macro attribute:

    The built-in macro attribute "binary" is equivalent to: [attr]binary -diff -merge -text