Skip to content

Instantly share code, notes, and snippets.

@troZee
Last active June 29, 2022 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troZee/13fa818b12200f7b382ccc397556981a to your computer and use it in GitHub Desktop.
Save troZee/13fa818b12200f7b382ccc397556981a to your computer and use it in GitHub Desktop.
How to generate changelog from git

Get diff on current branch

Command:

git --no-pager show -s --date=local --pretty=format:"- %h (%ae) %s%n"

Output:

- dcd509e (user@github.com) fix(ios): commit message 

Get diff from particular tags

Command:

git tag --sort=-creatordate | grep 'v5' | head -2 - when you need to filter a particular tag

git tag --sort=-creatordate | head -2 - without tag filtering

git log --pretty=oneline v5.4.23...v5.4.24 --date=local --pretty=format:"- %h (%ae) %s%n"

Output:

- dcd509e (user@github.com) fix(ios): commit message 

Integrate changelog with the fastlane

def get_changelog
  most_recent_tags = sh("git tag --sort=-creatordate | grep '^Release' | head -2").split("\n")
  commit_history = changelog_from_git_commits(
    between: most_recent_tags,
    pretty: "- %h (%ae) %s%n"
  )

  return commit_history
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment