QA
Senior LevelGit & GitHub

How do you write custom Git Merge Drivers in .gitattributes for specialized file formats?

❓ Interview Prompt: Explain custom Merge Drivers, .gitattributes driver assignment, placeholders (%O ancestor, %A current, %B incoming), and structural JSON/XML resolution.

Define custom merge drivers in .gitconfig (accepting %O, %A, %B placeholders) and assign them in .gitattributes to auto-resolve structural JSON/XML merge conflicts.

Code Implementation Example

ini
[merge "jq-json-merge"]
    name = Custom JSON Merge Driver
    driver = jq-merge-tool %O %A %B

package-lock.json merge=jq-json-merge
💡Configuring a custom structural JSON merge driver in .gitattributes.
🎯 Interview Key Takeaway

Define custom merge drivers in .gitconfig and assign them in .gitattributes to auto-resolve structural JSON/XML conflicts.

#Merge Drivers#.gitattributes#Conflict Resolution#Senior
Back to all Git & GitHub Questions→

More Git & GitHub Interview Questions

Beginner LevelGit & GitHub

Compare git rebase versus git merge and explain how git bisect finds regressions.

Beginner LevelGit & GitHub

What is the difference between git init and git clone?

Beginner LevelGit & GitHub

What are the Three Trees in Git (Working Directory, Staging Area / Index, Commit History)?