"git remote show origin":为什么所有分支都显示"tracked"即使有些不是呢?
即使那些分支未链接到本地分支进行拉/推,为什么"git remote show origin"仍将远程分支列为已跟踪"?在这种情况下,跟踪"是否意味着其他含义?我认为这就是"tracked"的全部意思:有关分支跟踪的git文档.
Why does "git remote show origin" list remote branches as "tracked" even when those branches are not linked to a local branch for pull/push? Does "tracked" mean something else in this context? I thought that was the whole meaning of "tracked": git docs on branch tracking.
1)克隆具有多个远程分支的存储库
1) clone a repo with more than one remote branch
2)运行git remote show origin
-表示已跟踪"testBranch".但是git branch -vv
正确显示仅母版跟踪源/母版,而git branch -a
正确显示仅一个本地分支母版.
2) run git remote show origin
-- says "testBranch" is tracked. But git branch -vv
correctly shows only master tracking origin/master, and git branch -a
correctly shows that there's only the one local branch, master.
3)那么:git remote show origin
将testBranch列为"tracked"是什么意思?需要明确的是:事情的设置没有错误":一切正常.我只是不明白为什么将远程testBranch标记为已跟踪".这就是我想要的答案.
3) So: what does git remote show origin
mean when it lists testBranch as "tracked"? To be clear: there's nothing "wrong" with how things are setup: everything works fine. I just don't understand why the remote testBranch is labeled as "tracked". That's what I want an answer to.
hawk@Tug:~/temp/TestRepo (master)$ git remote show origin
* remote origin
Fetch URL: git@github.com:haughki/TestRepo.git
Push URL: git@github.com:haughki/TestRepo.git
HEAD branch: master
Remote branches:
master tracked
testBranch tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
hawk@Tug:~/temp/TestRepo (master)$ git branch -vv
* master 8df130e [origin/master] shoulda done this last time
hawk@Tug:~/temp/TestRepo (master)$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/testBranch
git remote show
提到的跟踪"与git branch -vv
所说的跟踪"不同,发生在git checkout -b <branch> <upstream>
上. (或者不同"一词太强了,因为基本思想是相同的,它是在谈论存储库中的远程跟踪分支,而不是您是否有一个本地分支恰好将其中一个作为上游分支)
The "tracked" that git remote show
mentions is different from the "tracking" that git branch -vv
talks about, that occurs with git checkout -b <branch> <upstream>
. (Or maybe "different" is too strong a word, since the underlying idea is the same, it's talking about the remote-tracking branches in your repository, rather than whether you have a local branch that happens to have one of those as its upstream.)
尤其是,git remote show
检查给定遥控器的fetch =
行,并将其与遥控器上现在实际可用的参考进行比较(运行git ls-remote
来查看这些参考).
In particular, git remote show
examines the fetch =
line(s) for the given remote, and compares this with the references actually available now on the remote (run git ls-remote
to see those).
名为origin
的远程服务器的默认fetch =
行显示为:
The default fetch =
line for the remote named origin
reads:
fetch = +refs/heads/*:refs/remotes/origin/*
请注意两个*
.左侧的一个匹配远程存在的所有分支,而右侧的一个则表示替换与左侧匹配的相同名称".
Note the two *
s. The one on the left matches all branches that exist on the remote, while the one on the right means "replace with the same name matched on the left".
假设远程origin
当前具有以下引用:
Suppose that remote origin
currently has the following refs:
refs/heads/master
refs/heads/newbr
refs/tags/v1.2
refs/notes/commits
进一步假设分支newbr
自上次克隆,获取或以其他方式与远程origin
进行对话以来是新的,因此git branch -r
仅列出origin/master
,而不列出origin/newbr
.
Suppose further that branch newbr
is new since the last time you cloned, fetched, or otherwise talked to remote origin
, so that git branch -r
will only list origin/master
, not origin/newbr
.
如果您现在运行git remote show origin
,您将获得此位(以及其他内容):
If you now run git remote show origin
you will get (along with the other stuff) this bit:
master tracked
newbr new (next fetch will store in remotes/origin)
这意味着两个分支都匹配,并且您已经有refs/remotes/origin/master
,但是您还没有refs/remotes/origin/newbr
.
This means that both branches match, and you already have refs/remotes/origin/master
, but you do not yet have refs/remotes/origin/newbr
.
运行git fetch
后,您将获得origin/newbr
.但是,如果在运行git fetch
之前更改了fetch =
行,从而使不会获取origin/newbr
,则git remote show origin
将停止提及它.
Once you run git fetch
, you will acquire origin/newbr
. But if, before you do run git fetch
, you change your fetch =
line so that you won't acquire origin/newbr
, git remote show origin
will stop mentioning it.