1

Assume the following situation:

  1. Create a file with contents Hello World!, add it, commit.
  2. Change it to Hi World! in one branch, and to Hello World in another branch.
  3. Now merging them will result in a conflict, because both changes are on the same line.

Consider the alternative where we separate the changes on different lines: 1. Create a file with contents Hello\nWorld\n!. (I'm denoting a line break by \n.) 2. Apply the analogous changes as before. 3. Now suddenly merging will work.

But a line break is a character like any other. Why does merging treat it so special?

More importantly, are there git-compatible merge tools that will merge my first example without conflicts, i.e. is it possible to merge changes within a line?

Turion
  • 5,684
  • 4
  • 26
  • 42
  • I don't understand why this was migrated to stackoverflow. It's about using a tool, not about programming. Also, a helpful comment was deleted in the process. – Turion Jul 18 '18 at 09:21
  • A similar question asking for word-by-word merge is https://stackoverflow.com/questions/5587626/git-merging-within-a-line – Turion Jan 14 '19 at 13:23

1 Answers1

-1

All (standard) merge-tools in all VCSes are line-based (just because diff, patch under the hood are line based and line of text is atom, nor bigger nor smaller objects are even evaluated)… and I'll try don't mention "context" and "unifed" formats of diff and related "hunks" headache

Common answer for your question - "No, there are not such mergers (at least well-known and from reputable sources) in wild Net now. But - you can write it and use as special custom merge-tool in Git"

PS - Smudge|Clean filters approach from linked answer seems as a more promising (at least for me) solution

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110