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
1
vote
2 answers

`git log` shows notes that `git notes` doesn't

I'm using stepup to manage git notes that are used to automate version numbering and release notes. The notes in one of our repos seem to be messed up: $ git log HEAD commit 04c85f5ad7e5d60de8c9f0b8e08681e833751909 Author: Daniel Serodio…
Daniel Serodio
  • 4,229
  • 5
  • 37
  • 33
1
vote
2 answers

Git blobless repository

I'm wondering if there's a way to get commit and tree objects only from a remote. This may sound like a silly question, I'm not sure—I'm new to git plumbing. I'm building an app that associates meta-data with git commits, authorships, and file…
Chris Keele
  • 3,364
  • 3
  • 30
  • 52
0
votes
1 answer

How can I fetch notes from a remote git repository with TortoiseGit?

A typical use of 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 (Git-notes documentation). With TortoiseGit I can create a note by Edit notes context…
Christoph Jüngling
  • 1,080
  • 7
  • 26
0
votes
1 answer

git overrides refs/notes when fetching?

I'm keeping my changelog in git-notes --ref changelog when developing. I'm always putting a note on the merge-to-master commit and push it out to three remotes (git push refs/notes/changelog) - but every time I forget to push to one remote…
musicmatze
  • 4,124
  • 7
  • 33
  • 48
0
votes
1 answer

How to read Git notes using JGit given a commit-sha

I am trying to read Git Notes information from a custom ref refs/notes/abcd of a particular commit in a repository using JGit Here is what I tried: Repository repository = repositoryManager.openRepository(repoName); Git git = new…
0
votes
0 answers

cannot push git notes to remote

For some reason I cannot push the notes from my local git repository to the remote repository. git log, shows the notes after each commit, but if I perform: git push origin refs/notes/* I get Everything up-to-date But notes are not really…
Marinos An
  • 9,481
  • 6
  • 63
  • 96
0
votes
1 answer

How to make git notes to pull automatically for everyone who clones repo?

Is it possible at all? I've read in documentation that you can configure it in your local .git/config like: [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* But it is local settings and as i understand i can't push it to i.e. github…
Kirill
  • 6,762
  • 4
  • 51
  • 81
0
votes
1 answer

Push notes to remote git repository

I recently came across some old paper documentation for a project I have archived in Git that is not reflected in the commits. Not wanting to rebase and amend all the various commits and rewrite history I decided to add the new found information via…
Trashman
  • 1,424
  • 18
  • 27
1 2
3