Gitflow: 禁止直接提交到 master

创建于 2013-07-12  ·  17评论  ·  资料来源: nvie/gitflow

为了遵循 Git-Flow,我们应该禁止直接提交到 master 分支,目的是用户应该使用发布或修补程序来提交到 master 分支。

最有用的评论

要禁止在 master 上提交,请编辑 hooks 目录中的挂钩文件pre-commit

添加以下代码以首先运行:

branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
    echo "Direct commits to the branch master are not allowed"
    exit 1
fi

所有17条评论

我同意你的看法。

要禁止在 master 上提交,请编辑 hooks 目录中的挂钩文件pre-commit

添加以下代码以首先运行:

branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
    echo "Direct commits to the branch master are not allowed"
    exit 1
fi

@petervanderdoes :这些行包含在您的 fork 中吗?

@HassanChef 没有

您不能在 git-flow 中包含这些行,因为它是由git commit触发的钩子,而不是 git-flow 命令。 有关 git hooks 的更多信息,我建议阅读:http: //git-scm.com/book/en/Customizing-Git-Git-Hooks

@petervanderdoes非常感谢,它就像一个魅力:)

可以扩展 git-flow-init 来添加这个钩子吗?

@samkelett 没有

如前所述:您不能在 git-flow 中包含这些行,因为它是由 git commit 而不是 git-flow 命令触发的钩子。

对不起,我错过了你的回复! 当您执行git flow init时,git flow 是否可以在.git/hooks目录中的pre-commit文件中创建(或提供创建选项)该 bash 脚本?

@samkellett git flow init的目的是什么? 该命令不提交任何内容,它只是创建一个生产和开发分支(如果它们不存在)并将所需的信息添加到.git/config文件中。

我只是认为它设置了环境,其中一部分是你不应该再提交给 master,在创建 git flow 设置时安装钩子会强制执行新的区别

@samkelett我明白了。

好主意。 可能在contrib目录中分开,例如 git 中的completion

是的,这可以工作!

只是提醒一下,它不会被添加到这个 repo 中。 这个 repo 已经 2 年没有更新了。

哈哈,是啊..!

@petervanderdoes ,感谢您的脚本。 但是如何添加用户明智的分支推送限制?

我用的是coco.os的界面

2016 年 11 月 2 日 11:21,Fahad Ahammed [email protected]写道:

@petervanderdoes ,感谢您的脚本。 但是如何添加用户明智的分支推送限制?


您收到此消息是因为您订阅了此线程。
直接回复此电子邮件,在 GitHub 上查看它,或将线程静音。

你想要 ssh rsa 密钥吗?

2016 年 11 月 2 日 11:21,Fahad Ahammed [email protected]写道:

@petervanderdoes ,感谢您的脚本。 但是如何添加用户明智的分支推送限制?


您收到此消息是因为您订阅了此线程。
直接回复此电子邮件,在 GitHub 上查看它,或将线程静音。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

sbellware picture sbellware  ·  12评论

RoLYroLLs picture RoLYroLLs  ·  4评论

nvaken picture nvaken  ·  5评论

alexjeffburke picture alexjeffburke  ·  24评论

nvie picture nvie  ·  10评论