标签与 Git 中的分支有何不同?我应该在这里使用哪个? [英] How is a tag different from a branch in Git? Which should I use, here?

查看:28
本文介绍了标签与 Git 中的分支有何不同?我应该在这里使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解如何在 .

我刚刚从 ,现在我将针对特定功能处理该代码的子集.其他一些开发人员也将致力于此,但并非我们组中的所有开发人员都会关心此功能.我应该创建一个分支还是一个标签?在什么情况下我应该使用一种和另一种?

解决方案

标签 代表某一时刻特定分支的版本.分支代表一个单独的开发线程,可以与同一代码库上的其他开发工作同时运行.对一个分支的更改最终可能会合并回另一个分支以统一它们.

通常您会标记一个特定版本,以便您可以重新创建它,例如,这是我们运送给 XYZ Corp 的版本.分支 更像是一种策略,用于提供特定版本代码的持续更新,同时继续对其进行开发.您将创建已交付版本的分支,在主线上​​继续开发,但对代表已交付版本的分支进行错误修复.最终,您会将这些错误修复合并回主线.通常,您会同时使用分支和标记.您将拥有各种标签,这些标签可能适用于主线及其分支,标记沿着您可能想要重新创建的每个分支的特定版本(例如交付给客户的版本)——用于交付、错误诊断等.

它实际上比这更复杂 - 或者像您想要的那样复杂 - 但这些示例应该让您了解差异.

I am having some difficulty understanding how to use tags versus branches in .

I just moved the current version of our code from to , and now I'm going to be working on a subset of that code for a particular feature. A few other developers will be working on this as well, but not all developers in our group are going to care about this feature. Should I be creating a branch or a tag? In what situations should I be using one versus the other?

解决方案

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. Changes to a branch may eventually be merged back into another branch to unify them.

Usually you'll tag a particular version so that you can recreate it, e.g., this is the version we shipped to XYZ Corp. A branch is more of a strategy to provide on-going updates on a particular version of the code while continuing to do development on it. You'll make a branch of the delivered version, continue development on the main line, but make bug fixes to the branch that represents the delivered version. Eventually, you'll merge these bug fixes back into the main line. Often you'll use both branching and tagging together. You'll have various tags that may apply both to the main line and its branches marking particular versions (those delivered to customers, for instance) along each branch that you may want to recreate -- for delivery, bug diagnosis, etc.

It's actually more complicated than this -- or as complicated as you want to make it -- but these examples should give you an idea of the differences.

这篇关于标签与 Git 中的分支有何不同?我应该在这里使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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