git usage notes

Documentation

Commands I often forget

Committing

Rebase the last 3 commits:

git rebase -i HEAD~3

Rebase all commits:

git rebase -i --root

Working with remotes

Hard reset from remote:

git fetch
git reset --hard origin/master

Searching commits

Search for commits containing text:

git log --grep="abc"

Case-insensitive version:

git log -i --grep="abc"

Search by author

git log --author="guy"

Search for commits that modify a file or folder

git log -- path/to/file/or/folder

Find the oldest tag that contains a commit

git describe c2b0ce70add2a7dd6e792341c21278cb94820684

List contributors by commit count:

git shortlog --summary --numbered --all --no-merges