|
| 1 | +.. SPDX-FileCopyrightText: 2020 Veit Schiele |
| 2 | +.. |
| 3 | +.. SPDX-License-Identifier: BSD-3-Clause |
| 4 | +
|
| 5 | +Git Notes |
| 6 | +========= |
| 7 | + |
| 8 | +`Git Notes <https://git-scm.com/docs/git-notes>`_ add text notes to commits, |
| 9 | +tags and other objects. Such notes can contain all kinds of metadata, for |
| 10 | +example comments on code review, links to bug reports, :abbr:`etc (et cetera)`: |
| 11 | + |
| 12 | +#. Add a git note: |
| 13 | + |
| 14 | + .. code-block:: console |
| 15 | +
|
| 16 | + $ git notes add -m 'Example note' |
| 17 | +
|
| 18 | +#. Display a git note: |
| 19 | + |
| 20 | + .. code-block:: console |
| 21 | +
|
| 22 | + $ git log |
| 23 | + commit 859de540cda23f510f4ecbe0f38d07666e933f08 (HEAD -> main) |
| 24 | + Author: Veit Schiele <[email protected]> |
| 25 | + Date: Sun Mar 24 11:17:56 2024 +0100 |
| 26 | +
|
| 27 | + A commit message |
| 28 | +
|
| 29 | + Notes: |
| 30 | + Example note |
| 31 | +
|
| 32 | +#. Change a git note: |
| 33 | + |
| 34 | + .. code-block:: console |
| 35 | +
|
| 36 | + $ git notes edit |
| 37 | +
|
| 38 | +However, Git notes are not sent to the remote repository with ``git push`` or |
| 39 | +``git pull`` by default; they must be synchronised with ``git push origin |
| 40 | +'refs/notes/*'`` and ``git fetch origin 'refs/notes/*:refs/notes/*'``. |
| 41 | + |
| 42 | +.. warning:: |
| 43 | + Do not use ``git pull`` instead of ``git fetch``: you will not be able to |
| 44 | + merge ``refs/notes/commits`` with your current branch. |
| 45 | + |
| 46 | +.. note:: |
| 47 | + Git notes are not included in the git commit history, so they cannot be used |
| 48 | + for regulatory purposes where provenance, non-repudiation or tamper |
| 49 | + resistance must be proven. However, they can be useful for build tags and |
| 50 | + similar. |
| 51 | + |
| 52 | +.. seealso:: |
| 53 | + * `Git Notes: Git’s Coolest, Most Unloved Feature |
| 54 | + <https://tylercipriani.com/blog/2022/11/19/git-notes-gits-coolest-most-unloved-feature/>`_ |
| 55 | + * `git-appraise <https://github.com/google/git-appraise>`_ |
| 56 | + * `github-issues-git-notes |
| 57 | + <https://github.com/TomasHubelbauer/github-issues-git-notes>`_ |
0 commit comments