Created
May 15, 2025 02:22
-
-
Save ento/83738ba362356650f424b76e39ff93b7 to your computer and use it in GitHub Desktop.
git alias for calculating the number of lines changed since the 'parent' branch
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
[alias] | |
# Alias to get the nearest parent; adapetd from https://stackoverflow.com/a/17843908 | |
parent = "!git show-branch 2>/dev/null | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/[^\\[]*\\[\\([^\\[]*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #" | |
# Print the number of lines changed sicne the parent branch. e.g. branch-name +10 -10 | |
size = "!echo -n \"$(git parent) \"; git diff $(git parent)...HEAD --numstat | awk '{ additions+=$1; deletions+=$2 } END { print \"\\033[32m\" \"+\" additions \"\\033[0m\" \" \" \"\\033[31m\" \"-\" deletions }' #" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment