什么是 git 主题分支?

发布于 2024-07-08 23:25:08 字数 51 浏览 3 评论 0原文

什么是 git 主题分支? 它与普通分支有什么不同吗? 是否有任何分支不是主题分支?

What is a git topic branch? Does it differ from an ordinary branch in some way? Are there any branches that are not topic branches?

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

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

发布评论

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

评论(4

聚集的泪 2024-07-15 23:25:08

主题分支通常是您在本地创建的轻量级分支,并且其名称对有意义。 您可能会在其中进行错误修复或功能(也称为功能分支),预计需要一些时间才能完成。

另一种类型的分支是“远程分支”或“远程跟踪分支”。 这种类型的分支遵循其他人的工作的开发,并存储在您自己的存储库中。 您定期更新此分支(使用 git fetch )以跟踪其他地方发生的情况。 当您准备好赶上其他人的更改时,您可以使用 git pull 来获取和合并。

我还看到了另一种分支,它本质上是同一存储库中完全独立的文件树。 例如, Git 存储库本身 包含名为 manhtml 包含与 master 分支。 我不知道这些类型的分支通常被称为什么。

Topic branches are typically lightweight branches that you create locally and that have a name that is meaningful for you. They are where you might do work for a bug fix or feature (they're also called feature branches) that is expected to take some time to complete.

Another type of branch is the "remote branch" or "remote-tracking branch". This type of branch follows the development of somebody else's work and is stored in your own repository. You periodically update this branch (using git fetch) to track what is happening elsewhere. When you are ready to catch up with everybody else's changes, you would use git pull to both fetch and merge.

I have also seen another kind of branch which is essentially a completely separate tree of files in the same repository. For example, the Git repository itself contains heads named man and html that contain entirely different content from the master branch. I don't know what these types of branches are usually called.

擦肩而过的背影 2024-07-15 23:25:08

这不是一个技术术语;而是一个术语。 它只是指为实现特定功能或修复错误而创建的分支。 从本质上讲,“主题”是创建分支的原因。

It's not a technical term; it just refers to a branch that was created to implement a specific feature or fix a bug. The "topic" is the reason for the creation of the branch, essentially.

挽梦忆笙歌 2024-07-15 23:25:08

https://github.com/dchelimsky/rspec/wiki/Topic-Branches很好地解释了这一点:

“主题”分支是您在处理单个“主题”(错误修复、新功能或实验想法)时使用的单独分支。 建议在主题分支上工作,而不是直接在“master”之上,因为:

{...访问链接...}

因此,出于所有这些原因,建议使用主题分支来准备提交,即使是对于单提交错误修复等简单贡献也是如此。

该示例还给出了示例。 这实际上让我开始思考,这可能是大多数商店已经在做的事情。 我参与过的所有敏捷项目都是如此。 我对“这不是一个技术术语”投了赞成票,因为我觉得这击中要害。

https://github.com/dchelimsky/rspec/wiki/Topic-Branches explains this well:

A “topic” branch is a separate branch that you use when working on a single “topic” (a bug fix, a new feature, or an experimental idea). Working on a topic branch instead of directly on top of “master” is recommended because:

{... visit link ...}

So, for all of these reasons it’s recommended to use a topic branch for preparing submissions even for simple contributions like single-commit bugfixes and the like.

This sample also gives examples. Which actually got me to thinking, this is probably what most shops do already. All of the agile projects I've ever been with do. I upvoted th "It's not a technical term" because I feel this hits the nail on the head.

人疚 2024-07-15 23:25:08

看起来最突出和最重要的非主题分支类型是主要的公开可用存储库上的发布分支,对吗?

这可能适合您,但这与您和您正在考虑的项目有关; 它不是由 Git 决定的。

大多数版本控制系统(特别是集中式版本控制系统)都规定或强制执行特定的工作流程,包括使用分支的意义。 Git(以及某种程度上大多数分布式版本控制系统)认为工作流程、分支的用途、何时提交、不同的存储库的用途等都是由用户和用户之间的协议(策略)选择的。 所以 Git 并没有在技术上强制执行这些。

这是让我很难学习 Git 的原因之一。 Oliver Steele 从用户的角度解释了这一点,撰写了有关提交策略的文章。

it looks like the most prominent and important type of branches that aren't topic branches would be release branches on a major, publicly-available repository, right?

That's probably right for you, but that's about you and the project you're thinking about; it's not determined by Git.

Most version control systems (particularly centralized ones) prescribe or enforce a particular workflow, including what it makes sense to use a branch for. Git ( and to some extent most distributed VCSs) consider that workflow, what branches are used for, when to commit, what different repos are used for, etc. is all chosen by the users and agreements among the users (policies). So Git doesn't enforce these technically.

This is one of the things that made Git hard for me to learn. Oliver Steele explained this from user's view, writing about Commit Policies.

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