在Git中创建新分支时,我可以添加消息/注释/注释吗? [英] Can I add a message/note/comment when creating a new branch in Git?

查看:3793
本文介绍了在Git中创建新分支时,我可以添加消息/注释/注释吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一些探索性的工作,我很可能在同一个任务的几个不同的变化上花费30分钟。我想在git中跟踪它们,所以我可以在两种方法之间来回跳转。如果有3或6或9个分支,我可能需要一些更多的信息比分支名称来告诉他们。



什么是最干净的方式附加注释

解决方案

您需要分支说明:

  git branch --edit-description 

编辑器,并允许您将元数据附加到分支。您可以通过以下方式解压缩:

  git config branch。< branch> .description 

几个重要注意事项:


  1. 这是本地存储的。根据定义,它不能被推送,因为它存储在 .git / config

  2. 如果您删除分支,说明也会一并删除。

  3. 如果您设置 git config --global branchdesc true ,您可以将此描述推送到合并提交。这意味着当你发出 git merge -log< branch> 时,它会强制分支描述到股票合并提交消息。这有很多用途。例如,这是我在我的雇主跟踪主题分支发布说明。



I'm doing some exploratory work where I will most likely be spending 30 min on several different variations of the same task. I want to track them in git so I can jump back and forth between approaches. And if there are 3 or 6 or 9 branches, I might need some more info than the branch name to tell them apart.

What is the cleanest way to attach a comment to a new branch?

解决方案

You want branch descriptions:

git branch --edit-description

This will open up your editor and let you attach metadata to the branch. You can extract it with:

git config branch.<branch>.description

A couple of important notes:

  1. This is stored locally. By definition it can't be pushed since it's stored in .git/config. All the same it works great for this use case.

  2. If you delete the branch, the description will delete as well.

  3. You can push this description into merge commits if you set git config --global branchdesc true. This means when you issue git merge --log <branch>, it'll force the branch description into the stock merge commit message. This has a lot of uses. For example, this is how I track topic branch release notes at my employer.

这篇关于在Git中创建新分支时,我可以添加消息/注释/注释吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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