Skip to content

Instantly share code, notes, and snippets.

@vuljormp
Last active July 14, 2023 01:21
Show Gist options
  • Save vuljormp/f3a642ea7d9e22180e713093ffce9247 to your computer and use it in GitHub Desktop.
Save vuljormp/f3a642ea7d9e22180e713093ffce9247 to your computer and use it in GitHub Desktop.
Git Alias

rvfrom

View revisons from certain commit to head
git rvfrom [hash|branch|tag]

git config --global alias.rvfrom '!\
f(){
    if test -n "$1"; then
        git rev-parse "$1" >/dev/null 2>&1 || { echo Unknown revision "$1"; return; }
        rev="$1..";
    fi;
    git log --pretty="* %s" $rev 2>/dev/null;
}; f'

search

Search commit with query text from log (case insensitive)
git search <query text> [numbers of commit, default to 1]

git config --global alias.search '!\
f(){
    test -z "$1" && return;
    number=1
    test -n "$2" && number=$(($2 + 0))
    git log --grep "$1" -i "-${number}" --pretty="%h %s";
}; f'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment