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→