git branch-t x y/z之后的.git/config的内容
假设git branch-t x y/z之后的.git/config的内容,git,Git,假设scratch是远程回购,bough是该回购中的一个分支。这意味着,git branch-r打印的其中一行将是scratch/bough。如果我现在执行 % git branch -t twig scratch/bough Branch twig set up to track remote branch bough from scratch. 然后检查.git/config的内容,我发现其中添加了一个新的部分: [branch "twig"] remote = scrat
scratch
是远程回购,bough
是该回购中的一个分支。这意味着,git branch-r
打印的其中一行将是scratch/bough
。如果我现在执行
% git branch -t twig scratch/bough
Branch twig set up to track remote branch bough from scratch.
然后检查.git/config
的内容,我发现其中添加了一个新的部分:
[branch "twig"]
remote = scratch
merge = refs/heads/bough
merge
属性的值可能会让人认为存在一个文件.git/refs/heads/bough
,但实际上没有这样的文件。但是现在有一个文件.git/refs/heads/twig
:
.git/refs
├── heads
│ ├── master
│ └── twig
├── remotes
│ └── scratch
│ └── HEAD
└── tags
这让我意识到,行merge=refs/heads/bough
并不意味着我为什么会这么想(注意,该值引用了一个现有文件的路径,相对于.git
),或者git中有一个相当重要的bug
那么,让我们假设前者是这样。那么,行
merge=refs/heads/bough
真正的意思是什么?行merge
指的是远程回购中的ref,而不是本地回购中的ref。twig
的本地上游分支实际上将是refs/remotes/scratch/bough
作为记录,并非所有引用都作为文件存在于
.git/refs
中。您也可以拥有位于.git/packed refs
中的打包ref。合并行指的是远程repo中的ref,而不是本地repo中的ref。twig
的本地上游分支实际上将是refs/remotes/scratch/bough
[branch "twig"]
remote = scratch
merge = refs/heads/bough
作为记录,并非所有引用都作为文件存在于.git/refs
中。您还可以在.git/packed refs
中使用压缩的ref
[branch "twig"]
remote = scratch
merge = refs/heads/bough
此块表示以下内容:本地分支twig
设置为在远程scratch
上具有上游分支bough
,即scratch/bough
是远程跟踪分支。例如,当你在twig
上推动时,它会推动scratch/bough
此块表示以下内容:本地分支
twig
设置为在远程scratch
上具有上游分支bough
,即scratch/bough
是远程跟踪分支。例如,当你在twig
上推的时候,它会推到scratch/bough
因为scratch/HEAD
xDi不得不+1你的问题,因为scratch/HEAD
xD