首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在抓取时,git会超过参考文献/注释?

在抓取时,git会超过参考文献/注释?
EN

Stack Overflow用户
提问于 2018-04-24 16:15:51
回答 1查看 348关注 0票数 0

在开发时,我会在git-notes --ref changelog中保留我的变更量。我总是在合并到主提交时添加一个注释,并将其推送到三个遥控器(git push <remote> refs/notes/changelog),但是每次我忘记从它推送到一个远程和fetch时,这个ref就会被一些旧版本覆盖:

(德国地区抱歉)

代码语言:javascript
复制
$ git fetch github -p
Von github.com:<user>/<repo>
 + ca36d98d...1f3b9041 refs/notes/changelog -> refs/notes/changelog  (Aktualisierung erzwungen)

如何防止这种情况发生?这和我的.git/config有关系吗

(摘自.git/config):

代码语言:javascript
复制
[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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-24 17:02:39

你是对的。但是,您的fetch文件中的每一行都指定了一个--许多默认的fetch refspecs将使用其中之一,因此:

代码语言:javascript
复制
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 )存在于每个远程空间中:您将把originmaster提取到refs/remotes/origin/master中,这显然与refs/remotes/github/master不同。因此,至少对于所有普通用途,为这些名称强行获取是安全的:您不能覆盖位于refs/heads/中的自己的分支,也不能覆盖任何其他远程跟踪名称。

当然,对于refs/notes/中的notes引用,以及refs/tags/中的标记,这都不是正确的,因此,在这两种情况下,都要小心使用领先的+

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50006450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档