Skip to content

Instantly share code, notes, and snippets.

@james-pre
Last active May 5, 2024 16:37
Show Gist options
  • Save james-pre/4b66beda27ec3dc117e685360a5eeade to your computer and use it in GitHub Desktop.
Save james-pre/4b66beda27ec3dc117e685360a5eeade to your computer and use it in GitHub Desktop.
Useful `git` aliases
#!/bin/bash
# Adds some useful git aliases
echo "Adding aliases"
# Lists changes (i.e. commit messages)
# "- " prefixed before each line after any whitespace for easily making a markdown list
# You can optionally provide from and to tags.
# `git ls-changes` will list changes from the last tag to HEAD
# `git ls-changes tag_a` will list changes from tag_a to HEAD
# `git ls-changes tag_a tag_b` will list changes from tag_a to tag_b
git config --global alias.ls-changes '!f() { from=${1:-$(git describe --tags --abbrev=0)}; to=${2:-HEAD}; git log --format=%B "$from".."$to" | grep -v -e "^$" | sed "s/^\(\s*\)/\1- /"; }; f'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment