← Back to context

Comment by flohofwoe

2 days ago

Binary files can't be meaningfully merged. E.g. if two people create separate branches and work on the same Photoshop file, good luck trying to merge those changes, you can at best pick one version and the other user just wasted a lot of time. A lock communicates to other users "hey I'm currently working on that file, don't touch it" - this also means that lockable files must be write-only all the time unless explicitly locked - so that people don't "accidentially" start working on the file without acquiring a lock first. Apparently (as far as I have gathered so far from googling) git-lfs supports file locking but not vanilla git.

> Binary files can't be meaningfully merged.

I think we really need more development of format-specific diff and merge tools. A lot of binary formats could absolutely be diffed or merged, but you'd need algorithms and maybe UIs specific to that format - there is no "generic" algorithm like for text-based files. (And even there, generic line-wise diffing if often more "good enough" than really good)

I think it would be awesome if we could get "diff/merge servers" analogous to the "language servers" for IDEs some day.

  • Sounds like an infinite rabbit hole :)

    The alternative of preventing complex merge situations in the first place through file locking is low-tech, easy to implement, and automatically works on all current and future file formats.

    • Well, a concrete pain point where I had this problem was Unity scene files (a few years ago). Unity stored not just the assets but also the scene information in binary files, which made integrating that into git an absolute pain. (They made matters worse by also storing "last edit" timestamps in certain files, so git would show changes everywhere even if there weren't any. But that's another topic)

      The problem was that the scene information was fundamentally visual (assets arranged in 3D space) so even a diffable text format wouldn't help you much. On the other hand, scenes are large enough that you often would want to work on them in parallel with other people.

      I believe their first solution to that was the Asset Server that supported locking. But that still doesn't give two people the ability to work on a scene concurrently.

      Eventually, some users went and developed a custom diff/merge tool to solve the problem.

      https://discussions.unity.com/t/scene-diff-ease-your-sufferi...

      1 reply →

  • An alternative approach (less powerful but simpler) might be to reversibly convert the binary files into a mergeable text-like form before committing them.

    I've never done exactly that but I have occasionally decided how information will be represented in a data file with merging in mind.