修订号的 Git 等价物是什么? [英] What is the Git equivalent for revision number?

查看:21
本文介绍了修订号的 Git 等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在工作中使用 SVN,但对于我的个人项目,我决定使用 Git.所以我昨天安装了 Git,我想知道 Git 中的 修订号 等效是什么.

We use SVN at work, but for my personal projects I decided to use Git. So I installed Git yesterday, and I wonder what is the revision number equivalent in Git.

假设我们在 3.0.8 版上工作,并且每个错误修复都有自己的修订号,我们可以在谈论此错误修复时使用它.因此,如果我将 Git 中的代码标记为 3.0.8 那么我可以将其用作修订号或其他一些更详细的标识?我发现哈希对人类来说不太友好.

Let's say we work on version 3.0.8 and every bug fix has its own revision number we can use when we talk about this bug fix. So if I tag the code in Git to 3.0.8 what then I can use as a revision number or some other more detailed kind of identification? I find the hash not so user friendly for humans.

推荐答案

对你来说是好消息还是坏消息,散列是修订号.当我从 SVN 切换到 git 时,我也遇到了这个问题.

Good or bad news for you, that hash IS the revision number. I also had trouble with this when I made the switch from SVN to git.

您可以在 git 中使用标记"将某个修订标记为特定版本的发布",以便于引用该修订.查看此博文.

You can use "tagging" in git to tag a certain revision as the "release" for a specific version, making it easy to refer to that revision. Check out this blog post.

要理解的关键是 git 不能有修订号——想想去中心化的性质.如果用户 A 和 B 都提交到他们的本地存储库,git 如何合理分配顺序修订号?A 在 B 推/拉彼此的更改之前不知道 B.

The key thing to understand is that git cannot have revision numbers - think about the decentralized nature. If users A and B are both committing to their local repositories, how can git reasonably assign a sequential revision number? A has no knowledge of B before they push/pull each other's changes.

另一件需要注意的事情是错误修复分支的简化分支:

Another thing to look at is simplified branching for bugfix branches:

从一个版本开始:3.0.8.然后,在发布之后,执行以下操作:

Start with a release: 3.0.8. Then, after that release, do this:

git branch bugfixes308

这将为错误修正创建一个分支.结帐分支:

This will create a branch for bugfixes. Checkout the branch:

git checkout bugfixes308

现在进行任何您想要的错误修复更改.

Now make any bugfix changes you want.

git commit -a

提交它们,然后切换回主分支:

Commit them, and switch back to the master branch:

git checkout master

然后从另一个分支中提取这些更改:

Then pull in those changes from the other branch:

git merge bugfixes308

这样,您就有了一个单独的特定于版本的错误修复分支,但您仍然将错误修复更改拉入主开发主干.

That way, you have a separate release-specific bugfix branch, but you're still pulling the bugfix changes into your main dev trunk.

这篇关于修订号的 Git 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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