I'd like to keep a text file in my homedir called 'notes' which contains
all my notes to myself, and track this file and sync it between
computers using git. I write the file in markdown syntax and each new
entry usually begins with a header. So on machine A I add a new entry to
the top of my notes file:

    # A new entry written on machine A

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    # An old entry

    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

(Imagine the A's and C's being the contents of some notes, obviously.)
On machine B I also add a new entry, so both machines have modifications
to the file and a merge is going to be needed at some point:

    # A new entry written on machine B

    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

    # An old entry

    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

When I pull from machine B to machine A or vice-versa the merge fails
and git leaves the file looking something like this:

    <<<<<<< HEAD:notes.txt
    # A new entry written on machine A

    ======
    # A new entry written on machine B

    >>>>>> f228....

    <<<<<< HEAD:notes.txt
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    ======
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    >>>>>> f2281

    <<<<<< HEAD:notes.txt
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    ======
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    >>>>>> f2281

..and so on. Each entry A and B contains multiple paragraphs and git
interleaves the paragraphs of the two entries together, leaving a
complete mess for me to untangle. It's the worst thing git could
possibly do. If there are more than two entries to be merged at once
it's even worse.

Git is trying to merge commit A (which adds entry A to the top of the
notes file) and commit B (which adds entry B). They are two simple
commits, each one adds just one hunk of text to the file. I'd expect git
to put all the text of entry A followed by all the text of entry B and
then ask me to finish the merge, which would be trivial. But instead it
interleaves them?

So I have to resort to using a different text file for each note, which
avoids the problem unless I edit the same note on two machines (in which
case, fair enough). But multiple files sucks. It's much quicker and
easier to make a new note if I don't need to create a new file and come
up with a filename for it. I won't even bother to note down something
very quick or short if I'm going to have to come up with a filename.
It's much easier to find stuff in my notes if they're all in one file, I
can use my text editor's incremental search to jump around.
_______________________________________________
vcs-home mailing list
vcs-home@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-home

Reply via email to