gpt4 book ai didi

git - 提交后使用 git hook

转载 作者:太空狗 更新时间:2023-10-29 13:23:44 25 4
gpt4 key购买 nike

我刚刚开始编写 Web 应用程序。

我正在使用 GIT 进行版本控制,并且我在同一台计算机上安装了 git 和网络服务器。

应用程序有 3 个环境:开发、测试和生产

我想在每次提交后使用 git hook 来更新开发、测试或生产应用程序。

这方面的最佳做法是什么?

我需要这样的东西:

  1. 当我提交时,dev 必须自动更新
  2. 当提交消息在消息前面包含“test:”时 - 开发和测试必须更新。
  3. 当提交消息在消息前面包含“production:”时 - production、dev 和 test 必须更新。

谢谢!

最佳答案

我刚刚写了一个 hook/mini bash 脚本来解决这个问题

#!/bin/bash

if git log --pretty=format:%s -1 | grep -q "^test: "
then
#action / update dev/test
elif git log --pretty=format:%s -1 | grep -q "^production: "
then
#action / update dev/test/production
else
#action / update dev
fi

这是我的第一个 bash 脚本,所以..请帮助改进它:)

关于git - 提交后使用 git hook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7705040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com