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?
Notes can also be added to patches prepared with git format-patch by using the --notes option. Such notes are added as a patch commentary after a three dash separator line. To change which notes are shown by git log, see the "notes. displayRef" configuration in git-log[1].
A Git blob (binary large object) is the object type used to store the contents of each file in a repository. The file's SHA-1 hash is computed and stored in the blob object. These endpoints allow you to read and write blob objects to your Git database on GitHub. Blobs leverage these custom media types.
The git add command adds new or changed files in your working directory to the Git staging area. git add is an important command – without it, no git commit would ever do anything.
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With