Re: Can a note be pushed to origin?
- From
- Kristoffer 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