git 的标签和分支有什么区别?
可能的重复:
标签和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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
分支和标签本质上都是指向提交的指针。最大的区别在于,提交分支在添加新提交时指向更改,并且标记被冻结到特定提交以将时间点标记为具有一定的重要性。来自 Git 书籍:
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:
A branch in Git is simply a lightweight movable pointer to one of these commits.
来源:这个重复的问题。
您想要的可能是一个标签。
SOURCE: This duplicate question.
What you want is probably a TAG.
假设您有 - Super Awesome Product v1.0,它是稳定的并在 git 存储库中提交。
您在 v1.0 分支中进行错误修复和更改,并使用以下内容标记它们:
这修复了工作项 1341 - 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.
标签是 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.