What's the recommended usage of a Git symbolic reference?

前端 未结 3 1022
自闭症患者
自闭症患者 2021-01-01 14:03

The following shell code correctly creates a chain of symbolic references

git symbolic-ref \"first\" \"refs/heads/master\"
git symbolic-ref \"second\" \"firs         


        
相关标签:
3条回答
  • 2021-01-01 14:23

    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.

    0 讨论(0)
  • 2021-01-01 14:38

    Normally, symrefs live under refs/ — at least, this is what the git suite does (for example when using git filter-tree, you get refs/original/...). Some tools may choose to ignore refs that do not have the refs/ prefix.

    $ git symbolic-ref refs/first refs/heads/master
    $ git check-ref-format --print refs/first
    refs/first
    
    0 讨论(0)
  • 2021-01-01 14:39

    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.

    There are only two valid kinds of symrefs right now:

    • .git/HEAD, pointing at somewhere under refs/heads/ hierarchy;

    • .git/refs/remotes/{some remote name}/HEAD, pointing at somewhere under refs/remotes/{the same remote name}/ hierarchy.

    The code may be prepared to resolve recursive symrefs, symrefs other than the above two kinds, symrefs that point at elsewhere, but all of them are outside of the design scope of what the mechanism was intended to support. What the code do to them (without crashing) is not the design, but simply an undefined behaviour.

    This won't change very much if we decide to reorganize the remote tracking hierarchies in 1.8.0. The former won't change at all, and the latter will start pointing at refs/remotes/{the same remote name}/heads hierarchy instead.

    I vaguely recall tg abused the symref mechanism to point .git/HEAD at funny locations; it may still be doing so, and if that is the case we should extend the above list to cover that usage.

    0 讨论(0)
提交回复
热议问题