下面的 shell 代码正确地创建了符号引用链
git symbolic-ref "first" "refs/heads/master"
git symbolic-ref "second" "first"
git symbolic-ref "nested/third" "second"
git symbolic-ref "refs/heads/fourth" "nested/third"
并且下面的 shell 代码正确地将最新创建的符号引用解析为 master 的提示。
git show-ref "refs/heads/fourth"
官方文档中没有描述这些用例(git-symbolic-ref 文档,git-show-ref 文档)。
但是,以下内容不起作用
git check-ref-format --print "first"
所以,我的问题是:
- 可以在 refs/heads 目录中存储符号引用吗?
- 可以链接符号引用吗?
- 由于 check-ref-format 在传递
"first"
时失败,这是否意味着不建议在与 "HEAD"
相同的级别创建符号引用?或者也许这个命令不是为了处理符号链接?
我的目的是清楚地了解所支持的内容,并且我没有解决任何问题或从错误中受益。
The following shell code correctly creates a chain of symbolic references
git symbolic-ref "first" "refs/heads/master"
git symbolic-ref "second" "first"
git symbolic-ref "nested/third" "second"
git symbolic-ref "refs/heads/fourth" "nested/third"
And the following shell code correctly resolves the latest created symbolic reference to the tip of master.
git show-ref "refs/heads/fourth"
None of these use cases are described in the official documentation (git-symbolic-ref doc, git-show-ref doc).
However, the following doesn't work
git check-ref-format --print "first"
So, my questions are:
- Is it ok to store a symbolic reference within the
refs/heads
directory ?
- Is it ok to chain symbolic references ?
- As check-ref-format fails when being passed
"first"
, does this mean that it's not recommended to create a symbolic reference at the same level than "HEAD"
? Or maybe this command is not intended to deal with symbolic links ?
My intent is to get a clear understanding of what is being supported and that I'm not working around anything or benefiting from a bug.
发布评论
评论(3)
我最终将此问题发布到 git 开发邮件列表。
Junio C Hamano,首席 git 维护者(+8700 次提交)为我提供了以下答案。
I've eventually posted this question to the git development mailing list.
Junio C Hamano, the lead git maintainer (+8700 commits) provided me with the following answers.
通常,symrefs 位于
refs/
下 - 至少,这是 git 套件所做的事情(例如,当使用 git filter-tree 时,你会得到refs/original/...
)。某些工具可能会选择忽略没有refs/
前缀的引用。Normally, symrefs live under
refs/
— at least, this is what the git suite does (for example when using git filter-tree, you getrefs/original/...
). Some tools may choose to ignore refs that do not have therefs/
prefix.希望符号链接可以更透明地使用并且也可以推送。它们可能成为新工作流程的强大工具。目前,如果我创建一个符号链接,然后推送,服务器将拥有哈希而不是相应引用中的链接。
It would be desirable that symbolic links can be used more transparently and can be pushed as well. They could be a powerful tool for new workflows. Currently, if I create a symbolic link and then push is the server will have the hash not the link in the corresponding reference.