Questions tagged [git-notes]

A typical use of git notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log along with the original commit message. To distinguish these notes from the message stored in the commit object, the notes are indented like the message, after an unindented line saying "Notes ():" (or "Notes:" for refs/notes/commits).

When files are committed into a Git repository, they are addressed by a hash of the contents. The same is true of trees and commits. One of the benefits of this structure is that the objects cannot be modified after they have been committed (since doing so would change that hash).

However, sometimes it is desirable to be able to add metadata to a commit after it has already been committed. There are three ways of doing this:

Amend the commit message to add in the additional metadata, accepting this will change the branch. Create a merge node with a more detailed commit, and push that (so that the previous commit is retained and can be fast forwarded). Add additional metadata in the form of git notes. Of these three options, only the last one will not change the current branch.

Git Notes are, in effect, a separate ‘branch’ of the repository (stored at .git/refs/notes). They don’t show up in the git branch command (that lists .git/refs/heads by default). However, although you could check it out and manually update it, there is a command provided which helps you do that; git notes.

By default, notes are saved to and read from refs/notes/commits, but this default can be overridden. See the OPTIONS, CONFIGURATION, and ENVIRONMENT sections below. If this ref does not exist, it will be quietly created when it is first needed to store a note.

To change which notes are shown by git log, see the "notes.displayRef" configuration in git-log.

You can use notes to add annotations with information that was not available at the time a commit was written. e.g.

   $ git notes add -m 'Tested-by: Rachel Gallen<rg@kdbg.net>' 72a144e2
   $ git show -s 72a144e
   [...]
         Signed-off-by: Ruth Escat<gitster@pobox.com>

   Notes:
         Tested-by: Rachel Gallen <rg@kdbg.net>

Source

38 questions
3
votes
2 answers

`git notes append` creates additional blank line

Let's say I have git commit with git note: commit 385f6c188a5b1cef25acb6412ba4acd7c25b0b9c (HEAD -> master) Author: zuku Date: Tue Oct 8 14:14:31 2019 +0200 Test commit Notes: Test note Now I want to add some more text to this note: git…
Zuku
  • 1,030
  • 13
  • 21
3
votes
1 answer

Why repository size doubles when i copy notes?

I import SVN repository using Subgit, which is an excellent tool doing it fast and supporting custom svn layout. Subgit saves git commit -> svn revision reference in git notes. Every commit has revision number in notes, you can see it with git log.…
Kirill
  • 6,762
  • 4
  • 51
  • 81
3
votes
1 answer

How to use git metadata strategies compared to ClearCase ones?

In my previous developer life, clearcase was the tool, during 10+ years, for version control. Now the organisation I work for have moved over to git since 4 years. In clearcase there are easy accessible metadata constructions such as attributes on…
Mike
  • 397
  • 2
  • 16
3
votes
2 answers

Git notes perfomance and alternatives

We are using git at work for a large team (>100 developers) and I am writing different scripts to provide git statistics to management. One of the statistic that management wants to know is when commit was actually pushed to the repository. They…
mnaoumov
  • 2,146
  • 2
  • 22
  • 31
2
votes
1 answer

git rebase: merge notes into commit message

Given a commit with notes attached, can I take the message in the note and merge it into the commit's message when I do a rebase? The background of this question is that I have a large repository imported via git-tfs that has a huge amount of notes…
lanoxx
  • 12,249
  • 13
  • 87
  • 142
2
votes
1 answer

Git hooks with git notes?

Is it possible to use any git hooks with git notes? In other words, are any git hooks triggered by a git notes add -m "Some note"? I have tried a few hooks (update, post-commit) but so far none seem to be triggered on a git notes add.
Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184
2
votes
1 answer

Get all notes for a commit including their author and committer

Is there an easy way to retrieve all notes for a certain commit including information about the note author and the note committer? Using git show --notes=refs/notes/* I was able to get all notes. However I did not find out how to get…
Tim Keller
  • 389
  • 1
  • 12
2
votes
1 answer

Missing refs/notes when fetching in git

I have a situation where I'm attempting to fetch remote git notes using the following: git fetch origin refs/notes/*:refs/notes/* On a brand new clone of the repository, this works correctly. It pulls down 2 note namespaces: > git fetch origin…
loeschg
  • 29,961
  • 26
  • 97
  • 150
2
votes
2 answers

Why parent is stored in git notes?

The way git store notes: Git only store one note per commit for single namespace. One can have multiple namespace. Default namespace is commit. .git/refs/notes/ contain one hash (say, MainHash_2), which is a tree object. Whenever you create a note…
Abhishek Gupta
  • 6,465
  • 10
  • 50
  • 82
1
vote
2 answers

Remove trailing newline from %N format specifier in git-log

Is it possible to easily trim the newline when displaying a note with %N with git log? I would like to include metadata about a commit by adding it with git-notes and viewing it with something like: git log --format=format:'%h [%N] %an %s %D' This…
William Pursell
  • 204,365
  • 48
  • 270
  • 300
1
vote
2 answers

How do we exclude `Notes added by 'git notes add'` from `git log`?

How do we exclude Notes added by 'git notes add' from git log? When we run git log --all, there are millions of lines with Notes added by 'git notes add'. We need --all to see everything else. We just don't want the commits that add the notes.…
Fun Mun Pieng
  • 6,751
  • 3
  • 28
  • 30
1
vote
1 answer

git sign notes for push to central server

How do I add a note and sign it? Using BitBucket, repo has Verify Commit Signature Reject commits and tags without a verified GPG signature enabled. My build job adds a note to the commit that has just been built: 16:10:53 + git notes append…
Marc
  • 439
  • 2
  • 8
1
vote
1 answer

Add note to commit when filtering branch with Git

Next command is to store commit history and files lists but remove file contents in order to minimalize disk space and network traffic consumption when need to get know history of huge repo without fetching large objects. This allows to save much…
kyb
  • 7,233
  • 5
  • 52
  • 105
1
vote
0 answers

Git notes: attaching same note value with same namespace to multiple commits?

To add note with specific namespace, you can do it like this: git notes --ref=bugzilla add -m 'bug #15' 0385bcc3 But what if I need to specify it something similarly as with tags. Like from now (if not specified otherwise) all commits must have…
Andrius
  • 19,658
  • 37
  • 143
  • 243
1
vote
2 answers

Is there an Atlassian stash plugin to handle git notes?

Atlassian stash doesn't support git notes natively but notes are so useful for things like bug tracking, logging build results and so on that it boggles my mind there's no official support for it. Has anyone written a plugin to provide at least…
David Greene
  • 394
  • 2
  • 12