简体   繁体   中英

How to categorize git commits?

We have two separate projects on two different domains. Let's assume A project (the main) and B project. 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:

How can we find easily related commits among thousand of our commits on the GitLab site? 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. We cannot search and find those commits with labeling toward the merge request process (at gitlab.com).

GitLab isn't where you do your main work, it's where you publish it. 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 ". 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.

In my shop, this is managed through commit message prefix, using the Jira ticket 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.

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.

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.

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". Unfortunately, GitLab is not the best or recommended tool to work with this kind of git operation.

To know more about 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. 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

There are a lot of good GUIs free for Linux, Windows and MacOS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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