Skip to content

21st April 2022

Computer Science

GNULinux

Git

  • New: Merge conflict style.

    Take the pain out of git conflict resolution: use diff3

    git config --global merge.conflictstyle diff3
    

    After running this command to turn on diff3, each new conflict will have a 3rd section, the merged common ancestor.

    <<<<<<< HEAD
    GreenMessage.send(include_signature: true)
    ||||||| merged common ancestor
    BlueMessage.send(include_signature: true)
    =======
    BlueMessage.send(include_signature: false)
    >>>>>>> merged-branch
    
  • New: View file evolution.

    You can use git log -L to view the evolution of a range of lines. Example:

    git log -L 15,23:filename.txt
    

    means trace the evolution of lines 15 to 23 in the file named filename.txt.

  • New: Compare file accross references.

    To compare a file accross references (branches, tags, commits...) do:

    git diff <reference1> <reference2> -- <file>