Skip to content

Instantly share code, notes, and snippets.

@killbus
Last active December 29, 2021 17:47
Show Gist options
  • Save killbus/4b3f5a24fe96cb68c014f94fd8494af3 to your computer and use it in GitHub Desktop.
Save killbus/4b3f5a24fe96cb68c014f94fd8494af3 to your computer and use it in GitHub Desktop.
git utils commands etc.

delete all commits by a certain username

https://stackoverflow.com/questions/8058509/github-how-would-you-delete-all-commits-by-a-certain-username

keep changes

git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ];
    then
            skip_commit "$@";
    else
            git commit-tree "$@";
    fi' HEAD

list authors of a git repository including commit count and email

https://gist.github.com/wumpz/5846559

git shortlog -e -s -n

git shortlog -s -n --all --no-merges

add --no-merges to exclude statistics from merge commits.

To see the number of lines changed in the current working directory:

git diff --stat=10000

The output will look something like this:

1 file changed, 1 insertion(+), 1 deletion(-)

To see the number of lines changed in a git commit:

git diff --stat=10000 <commit>

This means you can see the number of lines changed for the most recent git commit:

git diff --stat=10000 HEAD~

To remove a dirty working directory from the diff, use git stash:

git stash

Pop the stash to restore it:

git stash pop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment