如何在Git中记录Web项目的发布历史记录? [英] How to record a history of releases for a web project in Git?

查看:88
本文介绍了如何在Git中记录Web项目的发布历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个频繁合并并发布到生产环境中的Web项目。我希望存储库包含所有曾经推送到生产服务器上的所有内容的完整记录,主要是为了能够在三个星期前分析错误日志条目,以确切了解当时生产的代码。



我不能使用 release 分支,因为在Git中,没有关于特定提交历史的概念科。我们当前使用版本分支,但它不能回答三周前生产的代码是什么的问题。



那么,我应该如何在Git中执行此操作?

解决方案

在git上使用。您可以阅读此处的标签。



根据您的问题,您可以列出所有标签,因此知道已发布的内容。这个在git scm-book上的例子是:

$ p $ git tag -l'v1.4.2。*'
v1.4.2.1
v1.4.2.2
v1.4.2.3
v1.4.2.4

签出一个特定的标签会让你处于与代码发布时完全相同的状态。



你甚至可以请注意:如果您有任何混淆的事情(无论是故意还是意外),GPG都会对这些标签进行签名,这可能会对共享存储库有所帮助。请注意:


默认情况下,git push命令不会将标签传输到远程
服务器。您必须在创建标签后将标签显式推送到共享服务器
。这个过程就像共享远程
分支 - 你可以运行git push origin [tagname]。


如果你认为它确实是令人头疼的。



和git一样,你真正需要的只是提交的内容,所以写下来可能就足够了,取决于你的需求。


I'm working on a web project with frequent merges and releases into production. I'd like the repository to contain a full record of everything that was ever pushed onto the production server, mainly so that I can analyse an error log entry from three weeks ago knowing exactly what code was in production at that time.

I cannot use a release branch for this because in Git, there is no concept of a history of commits made on a specific branch. We do use a release branch currently, but it does not enable me to answer the question of "what code was in production three weeks ago".

So, how should I do this in Git?

解决方案

Tags are intended for this kind of use on git. You can read about tags here.

As per your question, you can have a list of all tags, hence knowing what has been released. The example for this on git scm-book is:

$ git tag -l 'v1.4.2.*'
v1.4.2.1
v1.4.2.2
v1.4.2.3
v1.4.2.4

Checking out a specific tag would put you in the exact same condition as when the code was released.

You can even GPG sign the tags, which can be helpful in a shared repository, should you bother about anybody mixing things up (either on purpose or by accident).

Please note that:

By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches — you can run git push origin [tagname].

as this could result in a terrible headache if you assumed it did.

As always in git, all you really need is the sha of the commit, so that writing that down could be sufficient, depending on your needs.

这篇关于如何在Git中记录Web项目的发布历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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