Is there a way to find the important commits in GIT before a release?

github gitlab git-commit git-diff

72 просмотра

1 ответ

As in not only the major changes maybe the installed dependencies and all before a release without checking one by one?

Автор: Hasini Источник Размещён: 29.09.2019 08:28

Ответы (1)


0 плюса

Решение

Since Git won't know which commits are important to you, you'll have to first define your own set of guidelines/format on how you write your commit messages, which you can then use later on to easily differentiate all the commits made for a particular development period.

For example:

  • If it's a bug fix, prepend the commit message with a "[bugfix]"
  • If it's a new feature, prepend the commit message with a "[feature]"
  • If it's a project setup change, prepend the commit message with a "[migration]"

Then, once all the branches have been merged to the main branch (let's say it's develop), checkout the develop branch and use git log --grep=<PATTERN> to identify a specific set of commits.

For example, if you only need the bug fix commits, do a:

git log --grep="bugfix"

which will show you all the commits with "bugfix" in the commit message.

If you only need the commits for a specific period, you can use the --since=<date> option:

git log --since="2017-06-01" --grep="bugfix"

If you want a formatted list (something that you can easily output to some sort of release notes, I assume), you can use the --format=<format> option:

git log --since="2017-06-01" --grep="bugfix" --format="(%ci) %h : %s"

The command above will give you something like this:

(2017-06-18 18:26:36 +0800) 63f330f : [bugfix] prevent crash when dialog is sent to background
(2017-07-01 10:03:40 +0800) cdcbd91 : [bugfix] remove extra row at the end of the list

You can check out the other format options from the complete git log docs.

Basically, it will all depend on your commit message format.
As a tip, you can look into using a commit.template to make it easier to format your commit messages.

commit.template

If you set this to the path of a file on your system, Git will use that file as the default message when you commit. For instance, suppose you create a template file at ~/.gitmessage.txt that looks like this:

subject line

what happened

[ticket: X]

Автор: Gino Mempin Размещён: 27.08.2017 11:10
Вопросы из категории :
32x32