1

In a company, we have a project that we are working on for some time already. In this project we use git for versioning. We are trying to make our git workflow more professional and more easy to collaborate. One of the steps we want to take is automatically generate a changelog, e.g. with generate-changelog. This package requires that the commits our formatted following the Angular commit message format.

I will be happy to write all the commits in the future following this format, but we still have a lot (a couple of hundreds) of commits that do not follow this format. In the meanwhile, I want to have the changelog generated automatically.

Is there a way to generate the changelog automatically, although old commit messages do not follow the required format? Or could we possibly 'update' the commit message such that we do follow the required format?

In case you need more info, let me know and I will update the question accordingly.

Update: I want to prepend all old commit messages with some text like: docs:. Interactive rebase as suggested here and in the answer below does work, but only if you have a few commit messages. I am looking for a way to change all commit messages at once. An exmaple that I did not get to work yet can be found in this SO question/answer.

westr
  • 569
  • 5
  • 17
  • Hey @westr, could you solve your issue? If not, tell more and we will help you – artu-hnrq Mar 31 '21 at 00:21
  • 1
    Sorry, did not have so much time to continue with this this week. I tried yesterday and in priciple this works. However, via the interactive rebase I still need to manually change all the commit messages. Which is quite cumbersome when you have hundreds of commit messages. I am looking for a way to automatially prepend all the messages with text like "docs:". Something like https://stackoverflow.com/questions/14332551/whats-the-fastest-way-to-edit-hundreds-of-git-commit-messages. Although, I did not get this to work for me yet. Any ideas on this are also welcome.Updated my question accordingly – westr Apr 02 '21 at 09:21
  • Well, I comprehend your desire. It actually seems a quite different issue in progression of your resolution. Since that, I would ask you to consider accept the answer as it solves this question and, maybe, open another one specific for the new step when you have intention to proceed this demand. Anyway, nice that you're moving forward! – artu-hnrq Apr 02 '21 at 22:00
  • 1
    OK, fair enough. Will do so. – westr Apr 09 '21 at 13:16

1 Answers1

1

Well, considering you don't want to write a changelog file for your actual history, the option would be change old commit messages.

As explained in the linked answer you should run git rebase -i HEAD~n, where n is the number of commits you want to change. The --root flag can be used instead of HEAD~n to choose the whole history in the rebase command, as shown here:

git rebase -i --root

During the interactive rebase you will see each of selected commits in one line. And since you just want to rewrite its messages you can flag its line with the reword keyword, changing equivalent commit message as your desire

After that, save your changes and run generate-changelog to get your automatic changelog file

artu-hnrq
  • 1,343
  • 1
  • 8
  • 30