I recommend to look into git log --help and git rev-list --help .

I just created 2 scripts to list commits from Git repositories. It’s more in the score of an alias actually, so nothing comprehensive here. If you have some one-liners, alias or scripts for commits listing, please share here. The link of this post goes to the git log documentation. I’ll share mine in the comments too rather than in the post.

  • thingsiplay@lemmy.mlOP
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    8 days ago

    https://gist.github.com/thingsiplay/9ad7df1d743a5dafa4bef489801503f6

    gitlog:

    #!/usr/bin/env bash
    
    # List Git log messages by tag or commit range. Defaults to HEAD.
    #   gitlog [from] [to]
    #
    # from and to can be a tag or commit id:
    #   gitlog v1.22.2
    #   gitlog 281b532
    #   gitlog 281b532 b0353a6
    
    from="HEAD"
    to="HEAD"
    if [[ $# -ge 1 ]]; then
        from="${1-HEAD}"
        shift
    fi
    if [[ $# -ge 2 ]]; then
        to="${1-HEAD}"
        shift
    fi
    format="(%cr) %s"
    git --no-pager \
        log \
        --oneline \
        --decorate=no \
        --date=short \
        --abbrev-commit \
        --pretty=tformat:"${format}" \
        "${from}^..${to}^" \
        origin/master "${@}"
    

    gitlogdate:

    #!/usr/bin/env bash
    
    # List Git log messages since date. Defaults to today.
    #   gitlog [date]
    #
    # date can be a specific date %yyyy-%mm-%dd or description:
    #   gitlogdate 2026-11-03
    #   gitlogdate yesterday
    #   gitlogdate 3 weeks ago
    
    date="today"
    if [[ $# -gt 0 ]]; then
        date="${*-today}"
    fi
    format="%h %ad %s"
    git --no-pager \
        log \
        --oneline \
        --decorate=no \
        --date=short \
        --abbrev-commit \
        --pretty=tformat:"${format}" \
        --since-as-filter="${date}" \
        origin/master