3

So, the dev workflow for our project is like this: we create a task/bug ticket, and we branch off master to work on the task/bug, and eventually merge it back to master. We would like the commits on master to have nice messages. People committing on the task branch may not have good commit messages, and that's ok, but if the branch is to be merged, these commits with unclean messages are going into master.

One way to solve this is to always merge to master with --squash. That way, you get a chance to supply good commit message and treat the whole range of commits as one. I'm wondering if there's a way to enforce that? meaning, if we can let git server reject merges that aren't squashed?

4

3 に答える 3

8

直接強制するわけではありませんが、ブランチ--squashのデフォルトのマージ オプションとして設定できます。master

git config branch.master.mergeoptions  "--squash"

これにより、オプションを指定しなくても、マスターにマージされるコミットが常にスカッシュされ--squashます。

于 2012-05-17T06:22:50.193 に答える
1

必要なのは、プッシュされているものが必要なものであることを確認するためのサーバー側フックです。複数の非マージコミットを導入する参照変更を拒否します。コメントにチケット番号が含まれていることを確認するなど、他のチェックを行うことができます。

于 2012-05-16T21:05:11.127 に答える
0

ブランチで使用できますrebase -i。これにより、基本的にブランチのすべてのコミットを 1 つのコミットに押しつぶし、そのブランチ (1 つのコミット) をマスターにマージできます。

于 2012-05-16T16:10:12.540 に答える