-
-
Save wjljack/cb62bd395418283892f90ae5a3ac2ccc to your computer and use it in GitHub Desktop.
Git: Get commit count for specific folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| git log --name-only --pretty=format: -- $1 | sort | uniq -c | head -n 1 | |
| # --name-only = Show only names of changed files | |
| # --pretty=format: = Remove the information, leaving only filenames | |
| # -- $1 = Only show commits in that path (expected as argument) | |
| # first sort will make sure things are sorted, so ... | |
| # ... uniq -c can effectively merge all duplicates lines, counting them | |
| # The first line is the total number of commits in that folder, retrieved by head -n 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment