[英]How can I document a branch in a remote repository?
I'd like to add a brief description/rationale for the work being done on a branch. 我想为分支机构上所做的工作添加简短的描述/理由。 Only a sentence or two, but far more than can be communicated via the branch name.
仅一两个句子,但远远超过通过分支名称可以传达的数目。 Unfortunately, I haven't been able to find a clear way of accomplishing this.
不幸的是,我还没有找到一种清晰的方法来实现这一目标。
The git branch --edit-description
command would seem ideal except that, as it's stored in the repo config, it can't be pushed. 在
git branch --edit-description
命令似乎除了理想的,因为它存储在回购的配置,它不能推。 The documentation doesn't do much good if it can't be read by anyone else. 如果其他任何人都无法阅读,则该文档不会做得很好。 Two alternatives spring to mind, but both have problems with semantics.
我想到了两种选择,但都存在语义上的问题。
The first is to store the documentation within the repository content. 首先是将文档存储在存储库内容中。 I find this option unappealing both because it "contaminates" the repository content and because it has side effects — particularly when merging.
我发现此选项没有吸引力,因为它“污染”了存储库内容,而且还有副作用,尤其是在合并时。
The other is to use git commit --allow-empty
to create a commit with no changes. 另一种是使用
git commit --allow-empty
创建一个没有更改的提交。 This still breaks the semantics of the commit, but at least keeps metadata out of the repository. 这仍然破坏了提交的语义,但至少将元数据保留在存储库之外。
I'm currently inclined to use the empty-commit technique, but are there other alternatives? 我目前倾向于使用空提交技术,但是还有其他选择吗? Other problems I'm overlooking?
我忽略的其他问题?
What is the typical way to accomplish this? 完成此操作的典型方法是什么?
I'm not sure this is any better of an option but ... 我不确定这是否是更好的选择,但是...
Presuming this is a branch that isn't going to be rebased, then you could create an annotated tag with a similar name to the branch at the initial branch point, and then use the tag's commit message to describe the branch. 假设这是一个不会被重新设置基础的分支,那么您可以在初始分支点创建一个与分支名称相似的带注释的标签,然后使用标签的提交消息来描述该分支。
so instead of 所以代替
git checkout -b my_feature SOME_START_POINT
you would have 你将会拥有
git tag -m "Startpoint of the my_feature branch which is for ...." MY_FEATURE SOME_START_POINT
git branch my_feature MY_FEATURE
Or some other naming scheme like my_feature_start_point, etc. 或其他一些命名方案,例如my_feature_start_point等。
The information wouldn't be associated with the branch itself, but would be correlated in a way a human could figure out as needed. 信息不会与分支本身关联,而是会以人们可以根据需要找出的方式关联。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.