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 <remote> refs/notes/changelog) - but every time I forget to push to one remote and fetch from it, the ref gets overridden with some old version:
(Sorry for german locale)
$ git fetch github -p
Von github.com:<user>/<repo>
+ ca36d98d...1f3b9041 refs/notes/changelog -> refs/notes/changelog (Aktualisierung erzwungen)
How to prevent that? Is it somehow related to my .git/config?
(excerpt from .git/config):
[remote "github"]
url = [email protected]:<user>/<repo>.git
fetch = +refs/heads/*:refs/remotes/github/*
fetch = +refs/pull/*/head:refs/remotes/github/pr/*
push = +refs/notes/changelog:refs/notes/changelog
fetch = +refs/notes/changelog:refs/notes/changelog
[notes "rewrite"]
rebase = true
amend = true
[notes]
rewriteRef = refs/notes/changelog
You are correct. Each
fetchline in your.git/configfile specifies one of however-many default fetch refspecs Git will use, so:provides three such refspecs.
Each refspec consists of two main parts separated by a colon: on the left there is the source reference and on the right there is the destination reference. Asterisks
*may be used and act mostly like shell glob*(as a source only; the destination*is replaced with whatever the source*matched). If this pair is prefixed with a plus sign+, the update is always forced (as if you used--forceon the command line).Note that remote-tracking names such as
refs/remotes/github/masterexist in a per-remote space: you will fetchorigin'smasterintorefs/remotes/origin/masterwhich is clearly different fromrefs/remotes/github/master. Hence it's safe, at least for all ordinary purposes, to fetch with force for such names: you cannot overwrite your own branches, which are inrefs/heads/, nor any other remote's remote-tracking names.This is of course not true for notes references in
refs/notes/, nor for tags inrefs/tags/, so use care with leading+on either of those.