7

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?

Léo Léopold Hertz 준영
  • 126,923
  • 172
  • 430
  • 675
maxmelbin
  • 1,965
  • 3
  • 20
  • 27

1 Answers1

9

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 the notes/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.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755