0

I'm abble to list each author's contribution on inserted or deleted lines or character using git log like:

git log --shortstat --author "Steve Jobs"

But how to recursively exclude specific folders? If I want to list inserted lines of specific users without take into account the folder test (and all files it contains) he pushed?

If people had pushed a node_modules file, the number of inserted lines will drasticaly grow, I don't want to take them into account.

phd
  • 82,685
  • 13
  • 120
  • 165
Paul-Marie
  • 874
  • 1
  • 6
  • 24
  • Possible duplicate of [Making 'git log' ignore changes for certain paths](https://stackoverflow.com/questions/5685007/making-git-log-ignore-changes-for-certain-paths) – phd May 31 '19 at 13:45
  • https://stackoverflow.com/search?q=%5Bgit-log%5D+exclude+path – phd May 31 '19 at 13:45
  • I've already looked arround your links, but they only show each lines were inserted / deleted of each commit (excluding specifics files, good point). On very big project with more than 400 commit, should I count each inserted / deleted lines and add them to get the output? no... – Paul-Marie Jun 03 '19 at 07:58

1 Answers1

2

I finally achieved to do it:

To see the total's project inserted and deleted lines for the user toto excluding all content from node_modules, just do the following:

git log --shortstat --author="toto <toto.tata@tutu.tete>" -- . ":\!node_modules" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }'

it will output stat in format:

files changed: 31 lines inserted: 75293 lines deleted: 25

In the case you want an overview of each change applied by your coworkers (excluding specidic files) you only have to make a script to run this command with all repository's contributor (can be found with git log --format='%aN' | sort -u)

Paul-Marie
  • 874
  • 1
  • 6
  • 24
  • 1
    While this answer works to exclude ``files changed:``, it does not work for the lines inserted or deleted. Running the same command without the ``(exclude)`` path does not change the line counts. – WesH Dec 14 '20 at 18:16