简体   繁体   English

如何对 git 提交进行分类?

[英]How to categorize git commits?

We have two separate projects on two different domains.我们在两个不同的领域有两个独立的项目。 Let's assume A project (the main) and B project.让我们假设 A 项目(主要)和 B 项目。 Sometimes we need to use some specific feature that we have already launched on the A project on the B project with the git cherry-pick command, but there is a problem in this process:有时我们需要通过git cherry-pick命令在 B 项目上使用我们已经在 A 项目上启动的一些特定功能,但是在这个过程中会出现问题:

How can we find easily related commits among thousand of our commits on the GitLab site?我们如何在 GitLab 站点上的数千个提交中找到容易相关的提交? We are looking for a way for sticking a searchable label on our commits that specifies which commit is proper for the A project and which one for both of them.我们正在寻找一种在我们的提交上粘贴可搜索 label 的方法,以指定哪个提交适用于 A 项目,哪个提交适用于两者。 We cannot search and find those commits with labeling toward the merge request process (at gitlab.com).我们无法搜索并找到那些带有合并请求过程标签的提交(在 gitlab.com)。

GitLab isn't where you do your main work, it's where you publish it. GitLab 不是您主要工作的地方,而是您发布它的地方。 Anything beyond the basics you do in your local repo.除了您在本地仓库中所做的基础知识之外的任何事情。 Searchable labels on commits sounds like Git's notes facility, " A typical use of notes is to supplement a commit message without changing the commit itself ".提交上的可搜索标签听起来像 Git 的注释工具,“注释的典型用途是在不更改提交本身的情况下补充提交消息”。 It's the building blocks of a general labelling/searching facility, whatever you want for consequences to annotations you get to implement yourself.它是通用标签/搜索工具的构建块,无论您想要对自己实现的注释产生什么后果。 I have no idea what the GitLab merge mentioned here actually implemented, but they certainly know about it and people do use it for things like what you're describing.我不知道这里提到的 GitLab 合并实际实现了什么,但他们当然知道,人们确实将它用于您所描述的事情。

In my shop, this is managed through commit message prefix, using the Jira ticket ID.在我的商店中,这是通过提交消息前缀使用 Jira 票证 ID 进行管理的。

Each feature is implemented with a reference to a Jira ticket, and importing feature from one projet to another can be done a range of commit based on their commit message prefix.每个功能都是通过对 Jira 票证的引用来实现的,并且将功能从一个项目导入另一个项目可以根据其提交消息前缀完成一系列提交。

Beware of the inconvenients of cherry-picking though .不过要小心采摘樱桃的不便

In your case, the code cherry-picked from A to B might depend on other code from A not present in B.在您的情况下,从 A 到 B 精心挑选的代码可能取决于 A 中存在于 B 中的其他代码。

You can sign your commits with the #A-project prefix on your commit message then easily search your desired commits on Gitlab with a commit message.您可以在提交消息上使用#A-project前缀对提交进行签名,然后使用提交消息轻松搜索 Gitlab 上所需的提交。

In my company my team works with 5 customers at the same time, so we found a way to cherry-picking/merging a feature from one to another using tags to identify versions, changes, or a set of commits that need to be "copied".在我的公司,我的团队同时与 5 个客户合作,因此我们找到了一种方法来挑选/合并一个功能,使用标签来识别需要“复制”的版本、更改或一组提交”。 Unfortunately, GitLab is not the best or recommended tool to work with this kind of git operation.不幸的是,GitLab 不是使用这种 git 操作的最佳或推荐工具。

To know more about Tagging: https://git-scm.com/book/en/v2/Git-Basics-Tagging要了解有关标记的更多信息: https://git-scm.com/book/en/v2/Git-Basics-Tagging

I'd recommend you try using another tool like Git Tortoise (easy and extremely powerful) if you're using Windows.如果您使用的是 Windows,我建议您尝试使用其他工具,例如Git Tortoise (简单且非常强大)。 But if say this for you don't convince you, then I'd give you a tip to put some kind of pattern in the description of your commits to simply search for them later (It's not recommended).但是,如果对您说这些并不能说服您,那么我会给您一个提示,让您在提交的描述中加入某种模式,以便稍后简单地搜索它们(不推荐)。

To download some GUI Client for Git: https://git-scm.com/downloads/guis要下载 Git 的一些 GUI 客户端: https://git-scm.com/downloads/guis

There are a lot of good GUIs free for Linux, Windows and MacOS. Linux、Windows 和 MacOS 有很多好的免费 GUI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM