与Git持续集成 [英] Continuous integration with Git

查看:193
本文介绍了与Git持续集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Git的顶部提供集成钩子,当集成失败时推送被拒绝。例如,当开发人员推送他的更改时,我想检查项目是否仍然成功编译。

I would like to provide integration hooks on top of Git such that pushes get rejected when the integration failed. For example when a developer pushes his changes, I would like to check that the project still compiles successfully.

目前,我设置更新后钩子进行编译检查。但是,当我想拒绝推送,我还原更改并通知开发人员:

Presently, I setup the post-update hook to do the compilation checking. However when I want to reject the push, I revert the changes and inform the developer about it :

git revert --no-edit HEAD
echo "Rejected !"

我的问题是,当另一个开发者想推送他的更改,他必须先拉,工作,然后需要发出痛苦的重置/存储命令来正确合并。

此外,恢复将不工作在分支合并(需要-m选项)

My issue is that when another developer wants to push his changes, he has to pull first thus overriding his work and then needs to issue painful reset/stash commands to merge correctly.
Moreover, the revert will not work in case of branch merging (which needs the -m option)

我当前的解决方法是,而不是在服务器上恢复,我合并在另一个分支(这是我的开发人员的默认拉起源)的更改:

My current workaround is that instead of reverting on the server, I merge the changes in another branch (which is the default pull origin for my developers):

git checkout integrated
git merge master

推荐答案

最好的方法是给开发者自己的特性分支后更新钩子检查编译,然后将其合并到主(如果你想去所有偏执,你可以使钩子推到另一个分支,你手动合并到主)。这样你不必担心它被拒绝。在我看来,主人应该只用作发布分支,参考点不是每个人都推动一切。

Best approach for this would be giving developers their own feature branches which have post-update hook that checks the compiling and then merges it into master (If you want to go all paranoid on this you can make the hook push to another branch which you merge to master manually). This way you don't have to worry about it being rejected. In my opinion master should be only used as a release branch a reference point not something that everyone pushes everything to.

这篇关于与Git持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆