使用git提交时自动更改版本文件 [英] Change version file automatically on commit with git

查看:351
本文介绍了使用git提交时自动更改版本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有我们的master分支,我们将其功能合并到其中.作为合并的一部分,我需要能够在提交/合并到主服务器时自动增加我们的版本.有什么办法可以使升级版本作为此提交的一部分提交,而不必进行自动的重新结帐,更改,提交",这将使我们的所有提交有效地翻倍?

We have our master branch that we merge our features into. I need to be able to increment our version on commit/merge to the master automatically as a part of the merge. Is there a way i can do this so that the upped version is committed as a part of this commit without having to have an automatic 're checkout, change, commit' that will effectively double all our commits?

推荐答案

您可以使用 pre-commit挂钩.您可以通过删除.sample后缀并对其进行编辑,从.git/hooks/pre-commit.sample中的示例创建一个. pre-commit的内容将在提交之前执行.

The pre-commit hook specifically. You can create one from the sample in .git/hooks/pre-commit.sample by removing the .sample suffix and editing it. The content of pre-commit will be executed just before the commit.

它可能包含这样的内容

#!/bin/sh
command-that-increases-version version.text
git add version.text

version.text的任何修改都将包含在提交中.

Any modification of version.text will then be included in the commit.

这篇关于使用git提交时自动更改版本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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