git 的标签和分支有什么区别?

发布于 2024-09-28 15:59:04 字数 354 浏览 3 评论 0原文

可能的重复:
标签和git 中的一个分支?

我想做的是为我的代码的不同版本创建检查点。因此,一旦我进行了一堆提交,我想说,“好吧,在代码中的这一点上,这是 0.1 版本完成的”。然后我可以进行更多的提交并再次执行并说,“好吧,这一点已完成 0.2”。

我知道如何制作分支和标签......我只是不明白其中的区别,以及哪个会做我想要的;)

Possible Duplicate:
What is the difference between a tag and a branch in git?

What I'd like to do is create checkpoints for different versions of my code. So once I make a bunch of commits, I want to say, "Okay, at this point in the code, this is version 0.1 completed". And then I can make a bunch more commits and do it again and say, "Okay, this point is 0.2 completed".

I know how to make a branch and a tag... I just don't understand the difference, and which one will do what I want ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

海未深 2024-10-05 15:59:04

分支和标签本质上都是指向提交的指针。最大的区别在于,提交分支在添加新提交时指向更改,并且标记被冻结到特定提交以将时间点标记为具有一定的重要性。来自 Git 书籍

与大多数 VCS 一样,Git 能够
将历史中的特定点标记为
很重要。一般情况下,人们使用
此功能用于标记发布
点(v1.0 等)。在这个
部分,您将学习如何列出
可用标签,如何创建新标签
标签,以及不同类型的
标签是。

Git 中的分支只是指向这些提交之一的轻量级可移动指针。

Both branches and tags are essentially pointers to commits. The big difference is that the commit a branch points to changes as you add new commits, and a tag is frozen to a particular commit to mark a point in time as having a certain significance. From the Git Book:

Like most VCSs, Git has the ability to
tag specific points in history as
being important. Generally, people use
this functionality to mark release
points (v1.0, and so on). In this
section, you’ll learn how to list the
available tags, how to create new
tags, and what the different types of
tags are.

A branch in Git is simply a lightweight movable pointer to one of these commits.

苦笑流年记忆 2024-10-05 15:59:04

标签代表一个版本
某一时刻的特定分支。
一个分支代表一个单独的线程
可能运行的开发
与其他开发同时进行
在相同的代码库上努力。

来源:这个重复的问题

您想要的可能是一个标签

A tag represents a version of a
particular branch at a moment in time.
A branch represents a separate thread
of development that may run
concurrently with other development
efforts on the same code base.

SOURCE: This duplicate question.

What you want is probably a TAG.

优雅的叶子 2024-10-05 15:59:04

假设您有 - Super Awesome Product v1.0,它是稳定的并在 git 存储库中提交。

您在 v1.0 分支中进行错误修复和更改,并使用以下内容标记它们:

  • 这修复了工作项 1341 - bug ...

  • < p>此版本修复了项目 234324 - bug ...

  • final v1.0

以上都是代表状态的标签提交时的代码( LABEL )。因此,当您制作 v1.5 并且 v 1.0 出现错误时,您将使用标签 Final v1.0 并在其上测试错误。

现在!您决定更改 Super Awesome 产品的底层数据访问。你做什么工作?
您分支 v1.0 并创建一个名为 Super Awesome Product NEW DAL 分支的新分支。

标签用于每日提交的快照。分支是为了更大规模的改变。

Let's say you have - Super Awesome Product v1.0 that is stable and commited in a git repository.

You make bug fixes and changes in the branch that is v1.0 and you tag them with stuff like:

  • this fixes work item 1341 - bug ...

  • this version fixes item 234324 - bug ...

  • final v1.0

The above are all tags that represent the state of the code ( a LABEL ) when the commit was made. So, when you make v1.5 and a bug comes in for v 1.0, you take the tag final v1.0 and test the bug on it.

NOW! You decide to change the underlying Data Access of Super Awesome product. What do you do?
You branch v1.0 and make a new branch called Super Awesome Product NEW DAL branch.

Tags are for snapshots of daily to daily commits. Branches are for more grand scale changes.

知足的幸福 2024-10-05 15:59:04

标签是 git 的基本构建块;分支机构则不然。一旦创建指向提交,Git 就会执行检查以确保标签保持不变,永不更改。另一方面,分支仅仅是对提交的引用或指针,并且可以自由更新以指向不同的提交。

Tags are a fundamental building block in git; branches aren't. Git performs checks to make sure tags remain constant, never change, once created pointing at a commit. A branch on the other hand is a mere reference or pointer to a commit, and it can be updated to point at a different commit freely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文