git:“branchname”和“refs / head / branchname”之间的区别

最好在一个例子中解释:我在存储库的分支0.58,这是他如何拉:

git pull origin 0.58 

当我打电话给“git pull”时,我得到:

 ip238:openlierox az$ git pull You asked me to pull without telling me which branch you want to merge with, and 'branch.0.58.merge' in your configuration file does not tell me either. Please name which branch you want to merge on the command line and try again (eg 'git pull <repository> <refspec>'). See git-pull(1) for details on the refspec. If you often merge with the same branch, you may want to configure the following variables in your configuration file: branch.0.58.remote = <nickname> branch.0.58.merge = <remote-ref> remote.<nickname>.url = <url> remote.<nickname>.fetch = <refspec> See git-config(1) for details. 

似乎我可能忘了一些选项(–track?),当我检查了分支。 无论如何,我已经设置了这个:

 git config branch.0.58.merge 0.58 git config branch.0.58.remote origin 

这似乎工作。 那么,仅仅是因为兴趣,我看了一些其他的分支关于这些设置:

 ip238:openlierox az$ git config branch.0.57.merge refs/heads/0.57 ip238:openlierox az$ git config branch.0.57.remote origin 

我现在想知道,“0.58”还是应该指定“refs / heads / 0.58”?

究竟有什么区别?

ref是指向提交的任何东西,例如分支(标题),标记和远程分支。 您应该在.git / refs目录中看到头部,远程部件和标签,前提是您的存储库中有三种types的引用。

refs / heads / 0.58指定了一个名为0.58的分支 。 如果你没有指定ref的名字空间,git会查找默认的。 这使得只使用0.58可以模糊 – 你可以有一个分支和一个名为0.58的标签。

只是对于一个很好奇的人来说–Git v1.8.2.2以后的git show-ref会显示你在本地仓库中的所有引用。