将Git注释添加到blob [英] Adding Git notes to a blob
问题描述
使用案例:应该可以向git构件添加元数据(如属性)。
p>我们计划为每个组件提供一个git repo,因此为每个提交对象应用一个便笺可以实现这个要求。
<现在,我们还需要一个组件内的文件的元数据(在这种情况下为git repo)。为此,我尝试将注释附加到作为提交一部分的Blob。
它接受笔记,甚至可以将笔记推送到中央仓库。
这是一个安全可靠的git使用情况吗?
是的,您可以这样使用 git笔记。
博客文章 Alex Blewitt 的Git Tip of the Week:Git Notes 提醒我们一些 git notes 优点和难点:
笔记不必是文本的,也不是他们必须是可合并的东西。
他们甚至不需要在notes / commits
ref;您可以根据任何参考创建笔记。
实际上, Gerrit 作品(我之前写过)。
Gerrit将其评论信息存储在Git存储库中的notes / review下。通常情况下,这不会显示出来(git日志只在笔记/提交refspace中显示注释)
Git Notes (存储在
.git / refs / notes
)
- 合并:由于笔记文件基本上位于其自己的分支上,所以内容不会与分支之间的合并合并。如果你想合并git笔记,那么在单独的行中按照
Key:Value
来实现git笔记合并必杀技。
注意到自我文章也指出推/拉笔记是如何不容易。
除了这两个问题(合并和推动)之外,你应该与你的' git notes
'用例保持一致。
I am trying to realize a use-case using git.
Use Case : It should be possible to add metadata (like Attributes) to git artifacts.
We plan to have a git repo for each component, so applying a note for each commit object could realize this requirement.
Now, it is also required that we have metadata for files within a component (git repo in this case). For this i tried to attach a note to a blob which was part of a commit.
It accepts the note and even I am able to push the notes to central repo.
Is this a safe and reliable usage of git notes for this use-case?
Yes, you can use git notes that way.
The blog post "Git Tip of the Week: Git Notes" from Alex Blewitt reminds us about some of the git notes
advantages and gotcha:
the notes don’t have to be textual, nor do they have to be something which is mergeable.
They don’t even need to be on thenotes/commits
ref; you can create notes based on any reference.In fact, this is how Gerrit works (which I’ve written about before).
Gerrit stores its review information in the Git repository under notes/review. Ordinarily, this doesn’t show up (the git log only shows notes in the notes/commits refspace)
Git Notes are, in effect, a separate ‘branch’ of the repository (stored at
.git/refs/notes
)merges: since the notes file is essentially on its own branch, the content doesn’t get merged with merges between branches. If you wanted to merge git notes, then following the
Key: Value
on separate lines is the way to achieve git note merging nirvana.
The "note to self" article also points out how pushing/pulling notes isn't exactly easy.
Beside those two issues (merging and pushing), you should be ok with your 'git notes
' use case.
这篇关于将Git注释添加到blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!