Skip to content

Instantly share code, notes, and snippets.

@przemyslawjanpietrzak
Last active March 3, 2020 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save przemyslawjanpietrzak/9884bae530942417cb904037fab7ac85 to your computer and use it in GitHub Desktop.
Save przemyslawjanpietrzak/9884bae530942417cb904037fab7ac85 to your computer and use it in GitHub Desktop.
# commits per conributor
git shortlog -s -n
# lines change per conributor
git log --author="<conributor_name>" --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }' -
# get repo lines count
git ls-files | xargs cat | wc -l
# git add to local ignore
git update-index --assume-unchanged [<file>...]
# change author of all commits
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Josh Lee" ];
then export GIT_AUTHOR_NAME="Hobo Bob"; export GIT_AUTHOR_EMAIL=hobo@example.com;
fi; git commit-tree "$@"'
# display parent branch
current_branch=$(git rev-parse --abbrev-ref HEAD | sed 's/\//\\\//'); git show-branch | awk -F'[]^~[]' '/\*/ && !/'"$current_branch"'/ {print $2;exit}'
# remove merged branches
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
# pretty log
git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment