简体   繁体   English

如何在远程存储库中记录分支?

[英]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.

相关问题 如何删除远程裸存储库的分支上的提交? - How can I remove a commit on a branch of a remote bare repository? 如何删除本地git存储库中的远程分支? - How can I delete a remote branch in a local git repository? 如何跟踪新的远程存储库的master分支? - How can I track the master branch of a new remote repository? 如何检查特定远程存储库分支是否包含特定的合并分支? - How can I check if a specific remote repository branch contains a specific merged branch? 如何在不克隆整个存储库的情况下显示远程git存储库的master分支的修订日期? - How can I show the revision date of a remote git repository's master branch, without cloning the whole repository? 为什么我不能删除远程GitLab存储库中的分支? - Why can't I delete a branch in a remote GitLab repository? 如何将许多扩展名定义的文件从一个远程存储库分支复制到另一个文件夹中的许多文件夹中? - How can I copy many files, defined by extension, in many folders, from one remote repository branch to another? Git-如何使用特定的远程分支作为存储库的上游源? - Git - How can I use a specific remote branch as the upstream source for a repository? 如何只获取远程 Git 存储库的一个分支? - How do I fetch only one branch of a remote Git repository? 如何更新远程分支? - How can I update a remote branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM