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

  • Recovering from forgetting to .gitignore
  • How to do emergency fixes on master in git?
  • Progress indicator for git clone
  • Understanding Git for Visual Studio 2015: Revert
  • Single working branch with Git
  • Git Merge commits into an orphan branch
  • git log --follow --exclude-renames foo.sh
    

    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.