在开发时,我会在git-notes --ref changelog中保留我的变更量。我总是在合并到主提交时添加一个注释,并将其推送到三个遥控器(git push <remote> refs/notes/changelog),但是每次我忘记从它推送到一个远程和fetch时,这个ref就会被一些旧版本覆盖:
(德国地区抱歉)
$ git fetch github -p
Von github.com:<user>/<repo>
+ ca36d98d...1f3b9041 refs/notes/changelog -> refs/notes/changelog (Aktualisierung erzwungen)如何防止这种情况发生?这和我的.git/config有关系吗
(摘自.git/config):
[remote "github"]
url = git@github.com:<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发布于 2018-04-24 17:02:39
你是对的。但是,您的fetch文件中的每一行都指定了一个--许多默认的fetch refspecs将使用其中之一,因此:
fetch = +refs/heads/*:refs/remotes/github/*
fetch = +refs/pull/*/head:refs/remotes/github/pr/*
fetch = +refs/notes/changelog:refs/notes/changelog提供了三个这样的参数。
每个refspec由两个由冒号分隔的主要部分组成:左边是源引用,右边是目标引用。星号*可能被使用,其作用主要类似于shell glob * (仅作为源;目标*被替换为与*匹配的任何源)。如果这一对以加号+**,作为前缀,则更新总是强制的**(就好像您在命令行上使用了--force )。
请注意,远程跟踪名称(如refs/remotes/github/master )存在于每个远程空间中:您将把origin的master提取到refs/remotes/origin/master中,这显然与refs/remotes/github/master不同。因此,至少对于所有普通用途,为这些名称强行获取是安全的:您不能覆盖位于refs/heads/中的自己的分支,也不能覆盖任何其他远程跟踪名称。
当然,对于refs/notes/中的notes引用,以及refs/tags/中的标记,这都不是正确的,因此,在这两种情况下,都要小心使用领先的+。
https://stackoverflow.com/questions/50006450
复制相似问题