Skip to content

Instantly share code, notes, and snippets.

@vuon9
Created July 28, 2026 05:46
Show Gist options
  • Select an option

  • Save vuon9/3359eac5b0dacebb27a56df84f8abf6e to your computer and use it in GitHub Desktop.

Select an option

Save vuon9/3359eac5b0dacebb27a56df84f8abf6e to your computer and use it in GitHub Desktop.
show-me-git-change-logs.nu
def show-me-git-change-logs [
from_branch: string
to_branch: string = "master"
] {
print $"\nChangelogs for ($from_branch)...($to_branch):\n"
# Recent subjects on the target branch (fetched once instead of per-commit)
let recent = git log -n 100 --no-merges --pretty=format:%s $to_branch | lines
let changelogs = (
git log --oneline --no-merges --pretty=format:%s $"($from_branch)...($to_branch)"
| lines
| sort
| each {|commit|
if ($recent | any {|c| $c | str contains $commit }) {
$"- ($commit) (prev)"
} else {
$"- ($commit)"
}
}
| sort --reverse
| uniq
)
let prev_commits = $changelogs | where {|it| $it | str contains "(prev)" }
let new_commits = $changelogs | where {|it| not ($it | str contains "(prev)") }
if not ($prev_commits | is-empty) {
print "=== Merged commits (probably, as it matched to the commit on the target branch) ==="
print ($prev_commits | str join "\n")
print ""
print "=== New commits ==="
}
print ($new_commits | str join "\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment