git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Can a note be pushed to origin?

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
Sep 25, 2024, 15:29 UTC
Message-ID
<6b69af87-9002-46a7-a5f3-3fa1fb7ba9df@app.fastmail.com>
In-Reply-To
<20240925122515.14015-1-ishchis2@gmail.com>
Hi
On Wed, Sep 25, 2024, at 14:25, Stephen P. Smith wrote:
Show 9 quoted lines
> In a project that I am working on, some metadata is currently embedded in some
> source files.  The question was asked yesterday if there is a way to move that
> metadata a git specific file and link it to the source file or commit.
>
> I remembered that git has notes which can be used to add such data to a
> commit, but I don't believe that such metadata gets pushed to origin nor
> fetched from origin but another user.
>
> Is there a currently implemented way to do something like this?
You have to do it manually.
In `.git/config`:
```
[remote "origin"]
	url = <url>
        […]
	fetch = refs/notes/commits:refs/notes/commits
```
That fetches the default Notes ref on `git fetch origin`.

That will refuse to update if your own notes ever diverge from the remote. If you want to always overwrite your local notes with the remote ones:

```
[remote "origin"]
	url = <url>
        […]
	fetch = +refs/notes/commits:refs/notes/commits
```
But then you should also enable reflog updates for all refs:

``` git config set --global core.logAllRefUpdates always ```

In case you do a fetch that you want to undo.
-- 
Kristoffer Haugsbakk
Previous: Stephen P. SmithNext: Jeff King
Message 2 of 4 in “Can a note be pushed to origin?”
  1. Stephen P. SmithSep 25, 2024
  2. Kristoffer HaugsbakkSep 25, 2024
  3. Jeff KingSep 27, 2024
  4. Kristoffer HaugsbakkSep 28, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.