Skip to content

Instantly share code, notes, and snippets.

@phanect
Last active July 29, 2024 06:02
Show Gist options
  • Save phanect/f6f3bd790585fc8f5a3ef5bd0fe0cfbb to your computer and use it in GitHub Desktop.
Save phanect/f6f3bd790585fc8f5a3ef5bd0fe0cfbb to your computer and use it in GitHub Desktop.
Collection of Git command snippets

Collection of Git command snippets

git clean -dX --force

List all committers in addition to the author on git log and git show.

git log --pretty=fuller | grep Author: | sort -u
git log --pretty=fuller | grep Commit: | sort -u

Check if PR includes changes in a specific directory

git switch $PR_BRANCH
git diff upstream/main HEAD -- $DIR_TO_COMPARE

Commands to replace all the committer emails in the commit logs

echo -e "Jumpei Ogawa <git@phanective.org> <phanect@users.noreply.github.com>\nJumpei Ogawa <git@phanective.org> <old@example.com>" | tee ./mailmap

git filter-repo --mailmap mailmap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment