git log exclude renames

I can list commits for a file, even if it has been renamed or moved

git log --follow foo.sh

However, I would like to “follow” the file, but only list commits where the file was actually changed. Something like

  • With git, how do I remove a local copy of a remote branch? Or at least pull without merging?
  • git pull with partial merge
  • Automatic documentation verification with Aspell before Commit
  • How do I stop git from adding carriage returns when cloneing a repo onto windows?
  • Git bash - show files in current directory
  • Using HoloEverywhere library
  • git log --follow --exclude-renames foo.sh
    

  • Commit count in Cake build script?
  • How to reuse pending comments after git commit fail?
  • git - two branches named the same? Difference is one lower case - one mixed case?
  • Can Git differentially store GZip files?
  • How to checkout a tag with GitPython
  • Git unstage lines where the only changes is white-space?
  • 2 Solutions collect form web for “git log exclude renames”

    A bit like in “nicely display file rename history in git log”, you could add --name-status in order to:

    • not select (grep -v renames: status ‘Rxxx‘, while keeping addition ‘A‘ or modification ‘M‘)
    • still follow the file through its different name

    But that will still involve post-processing the git log command (with grep and/or sed) in order to get the output you want: there is no native ‘--exclude-renames‘-like option yet.

    git log --follow --name-status --oneline foo.sh | sed 'h;N;/\nR/d;g'
    
    • copy commit line to hold space
    • read in second line
    • if line starting with R is found, delete pattern space and start next cycle,
      else copy hold space to pattern space

    thanks to jthill

    Git Baby is a git and github fan, let's start git clone.